Merhabalar,
Sisteminize ek olarak öncelikle kullanacağınız fonksiyondan kaynaklı aşağıdaki satırı eklemelisiniz.
using System.Threading.Tasks;
Sonrasında ise alış ve satış koşulunuzu if(flag) koşulu içerisine almalısınız.
Aşağıda gösterilmiştir.
if (flag)
{
if (ott.Value[1][ott.CurrentIndex] > ott.Value[0][ott.CurrentIndex]
&& stochasticSlow.Value[0][stochasticSlow.CurrentIndex] > stochasticSlow.Value[1][stochasticSlow.CurrentIndex]
&& HighLow.Value[0][HighLow.CurrentIndex - 1] < ohlcData1)
{
SendMarketOrder(Symbol1, OrderQuantity3, OrderSide.Buy, includeAfterSession:false, isReduceOnly : IsReduceOnly3);
StopLoss(Symbol1, SyntheticOrderPriceType.Percent, ZararDurdurYuzdesi);
}
if (ott.Value[1][ott.CurrentIndex] < ott.Value[0][ott.CurrentIndex]
&& stochasticSlow.Value[0][stochasticSlow.CurrentIndex] < stochasticSlow.Value[1][stochasticSlow.CurrentIndex]
&& HighLow.Value[1][HighLow.CurrentIndex - 1] > ohlcData2)
{
SendMarketOrder(Symbol1, OrderQuantity6, OrderSide.Sell, includeAfterSession:false, isReduceOnly : IsReduceOnly6);
}
}
}
Daha sonra ise stratejinizin en alt kısmına aşağıdaki methodu eklemelisiniz.
bool flag = true;
public override void OnSyntheticOrderTriggered(SyntheticAlgoOrder sOrder)
{
if (!sOrder.EnableOrderSending)
{
if (sOrder.SyntheticAlgoOrderType == SyntheticAlgoOrderType.TakeProfit)
flag = false;
Task.Run(async () =>
{
await Task.Delay(TimeSpan.FromMinutes(5));
flag = true;
});
}
Debug("Sentetik emir tetiklendi");
}
Buradaki method sizin sentetik emrinizin tetiklendiği anı algılayacak ve FromMinutes içerisinde bulunan sayı (dakika) kadar stratejinizi çalıştırmayacak.
Dilerseniz Matriks Deneme Ortamında BIST sembolü ile test ediniz.
Daha sonra düşük miktarda tekrar BINANCE hesabınızda çalıştırırsınız.
Formülün açık hali aşağıdadır, kontrol edebilirsiniz.
using System;
using System.Collections.Generic;
using System.Linq;
using Matriks;
using Matriks.Data.Symbol;
using Matriks.Engines;
using Matriks.Indicators;
using Matriks.Symbols;
using Matriks.Trader.Core;
using Matriks.Trader.Core.Fields;
using Matriks.Lean.Algotrader.AlgoBase;
using Matriks.Lean.Algotrader.Models;
using Matriks.Lean.Algotrader.Trading;
using Matriks.AI;
using Matriks.AI.AiParameters;
using Matriks.AI.Data;
using Matriks.Trader.Core.TraderModels;
using System.Threading.Tasks;
namespace Matriks.Lean.Algotrader
{
public class trade7 : MatriksAlgo
{
[SymbolParameter("BNB_USDT_FBIN")]
public string Symbol1;
[Parameter(SymbolPeriod.Min)]
public SymbolPeriod SymbolPeriod1;
[Parameter(30)]
public int OttPeriod1;
[Parameter(0.8)]
public decimal OttOpt1;
[Parameter(MovMethod.VAR)]
public MovMethod OttMovMethod1;
[Parameter(true)]
public bool OttSupportLine1;
[Parameter(500)]
public int StochasticslowPeriodK1;
[Parameter(111)]
public int StochasticslowPeriodD1;
[Parameter(200)]
public int StochasticslowPeriodSlowK1;
[Parameter(MovMethod.VAR)]
public MovMethod StochasticslowMovMethod1;
[Parameter(20)]
public int HighlowBarSayisi1;
[Parameter(false)]
public bool IsReduceOnly1;
[Parameter(10)]
public decimal Leverage1;
[Parameter(false)]
public bool IsReduceOnly2;
[Parameter(CryptoLeverageType.Isolated)]
public CryptoLeverageType LeverageType2;
[Parameter(0.0777)]
public decimal OrderQuantity3;
[Parameter(false)]
public bool IsReduceOnly3;
[Parameter(false)]
public bool IsReduceOnly4;
[Parameter(10)]
public decimal Leverage4;
[Parameter(false)]
public bool IsReduceOnly5;
[Parameter(CryptoLeverageType.Isolated)]
public CryptoLeverageType LeverageType5;
[Parameter(0.0777)]
public decimal OrderQuantity6;
[Parameter(99)]
public decimal ZararDurdurYuzdesi;
[Parameter(false)]
public bool IsReduceOnly6;
OTT ott;
StochasticSlow stochasticSlow;
MatriksIndicator HighLow;
public override void OnInit()
{
ott = OTTIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, OttPeriod1, OttOpt1, OttMovMethod1, OttSupportLine1);
stochasticSlow = StochasticSlowIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, StochasticslowPeriodK1, StochasticslowPeriodD1, StochasticslowPeriodSlowK1, StochasticslowMovMethod1);
HighLow = new HighLow();
HighLow.SetIndicatorParameters("BarSayisi", HighlowBarSayisi1);
RegisterUserIndicator(HighLow, Symbol1, SymbolPeriod1, OHLCType.Close, 5);
SetLeverage(Symbol1, Leverage1); SetLeverageType(Symbol1, LeverageType2);
SetLeverage(Symbol1, Leverage4); SetLeverageType(Symbol1, LeverageType5);
SendOrderSequential(true, Side.Buy);
WorkWithPermanentSignal(true);
}
public override void OnInitCompleted()
{
}
public override void OnTimer()
{
}
public override void OnDataUpdate(BarDataEventArgs barData)
{
var barData1 = GetBarData(Symbol1, SymbolPeriod1);
var ohlcData1 = GetSelectedValueFromBarData(barData1, OHLCType.High);
var ohlcData2 = GetSelectedValueFromBarData(barData1, OHLCType.Low);
if (flag)
{
if (ott.Value[1][ott.CurrentIndex] > ott.Value[0][ott.CurrentIndex]
&& stochasticSlow.Value[0][stochasticSlow.CurrentIndex] > stochasticSlow.Value[1][stochasticSlow.CurrentIndex]
&& HighLow.Value[0][HighLow.CurrentIndex - 1] < ohlcData1)
{
SendMarketOrder(Symbol1, OrderQuantity3, OrderSide.Buy, includeAfterSession:false, isReduceOnly : IsReduceOnly3);
StopLoss(Symbol1, SyntheticOrderPriceType.Percent, ZararDurdurYuzdesi);
}
if (ott.Value[1][ott.CurrentIndex] < ott.Value[0][ott.CurrentIndex]
&& stochasticSlow.Value[0][stochasticSlow.CurrentIndex] < stochasticSlow.Value[1][stochasticSlow.CurrentIndex]
&& HighLow.Value[1][HighLow.CurrentIndex - 1] > ohlcData2)
{
SendMarketOrder(Symbol1, OrderQuantity6, OrderSide.Sell, includeAfterSession:false, isReduceOnly : IsReduceOnly6);
}
}
}
public override void OnStopped()
{
}
bool flag = true;
public override void OnSyntheticOrderTriggered(SyntheticAlgoOrder sOrder)
{
if (!sOrder.EnableOrderSending)
{
if (sOrder.SyntheticAlgoOrderType == SyntheticAlgoOrderType.TakeProfit)
flag = false;
Task.Run(async () =>
{
await Task.Delay(TimeSpan.FromMinutes(5));
flag = true;
});
}
Debug("Sentetik emir tetiklendi");
}
}
}
İyi çalışmalar.