0 beğenilme 0 beğenilmeme
367 kez görüntülendi

Merhaba,

Timestamp hatası sonucu reddedilen emirden sonra emirler sıralı gitmeye devam ederek ikinci bir açığa satış yapmıştır. Böylece 2 adet açığa satış aktiftir. Ancak daha sonrasında sıralı gitmemiş ve emir 2 katı gerçekleşerek reddedileni de kapatmıştır. Eğer reddedilse dahi daha sonradan kapatılacaksa ikinci açığa satıştan önce kapanması gerekmezmiydi? Yada açığa satış kapatılırken biri açık kalması gerekmezmiydi? İşlemler aşağıdaki gibidir.

 

Algoritmik Trading kategorisinde (28 puan) tarafından | 367 kez görüntülendi

1 cevap

0 beğenilme 0 beğenilmeme
Merhabalar,

Kullandığınız sistemi paylaşabilirseniz inceleyip yardımcı olmaya çalışalım.

İyi çalışmalar.
(11,069 puan) tarafından
0 0

Merhabalar,

Kullandığım sistem şu şekildedir.

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;

namespace Matriks.Lean.Algotrader
{
	public class ShortSottTott2 : MatriksAlgo
	{
		// Strateji çalıştırılırken kullanacağımız parametreler. Eğer sembolle ilgili bir parametre ise,
		// "SymbolParameter" ile, değilse "Parameter" ile tanımlama yaparız. Parantez içindeki değerler default değerleridir.


		[SymbolParameter("SOL_USDT_FBIN")]
			public string Symbol1;


		[Parameter(SymbolPeriod.Min)]
			public SymbolPeriod SymbolPeriod1;



		[Parameter(41)]
			public int TottPeriod1;

		[Parameter(1.1)]
			public decimal TottOpt1;
		
		[Parameter(501)]
			public int SottPeriodK1;

		[Parameter(201)]
			public int SottPeriodSlowK1;
		
		[Parameter(42)]
			public int TottPeriod2;

		[Parameter(1.2)]
			public decimal TottOpt2;
		
		[Parameter(502)]
			public int SottPeriodK2;

		[Parameter(202)]
			public int SottPeriodSlowK2;
		
		[Parameter(43)]
			public int TottPeriod3;

		[Parameter(1.3)]
			public decimal TottOpt3;
		
		[Parameter(503)]
			public int SottPeriodK3;

		[Parameter(203)]
			public int SottPeriodSlowK3;
		
		[Parameter(44)]
			public int TottPeriod4;

		[Parameter(1.4)]
			public decimal TottOpt4;
		
		[Parameter(504)]
			public int SottPeriodK4;

		[Parameter(204)]
			public int SottPeriodSlowK4;

		[Parameter(0.0008)]
			public decimal TottTwinOttCoef1;
		
		[Parameter(0.35)]
			public decimal SottOttOpt1;
		
		[Parameter(0.0008)]
			public decimal TottTwinOttCoef2;
		
		[Parameter(0.35)]
			public decimal SottOttOpt2;
		
		[Parameter(0.0008)]
			public decimal TottTwinOttCoef3;
		
		[Parameter(0.35)]
			public decimal SottOttOpt3;
		
		[Parameter(0.0008)]
			public decimal TottTwinOttCoef4;
		
		[Parameter(0.35)]
			public decimal SottOttOpt4;
		
		[Parameter(30)]
			public int OttPeriod1;

		[Parameter(7)]
			public decimal OttOpt1;
		
		[Parameter(21)]
			public int HighlowBarSayisi1;

		[Parameter(22)]
			public int HighlowBarSayisi2;

		[Parameter(23)]
			public int HighlowBarSayisi3;

		[Parameter(24)]
			public int HighlowBarSayisi4;	

		[Parameter(MovMethod.VAR)]
			public MovMethod TottMovMethod1;

		[Parameter(MovMethod.VAR)]
			public MovMethod TottMovMethod2;

		[Parameter(MovMethod.VAR)]
			public MovMethod TottMovMethod3;

		[Parameter(MovMethod.VAR)]
			public MovMethod TottMovMethod4;

		[Parameter(2)]
			public int SottOttPeriod1;

		[Parameter(MovMethod.VAR)]
			public MovMethod SottOttMethod1;

		[Parameter(MovMethod.VAR)]
			public MovMethod SottStosKMethod1;

		[Parameter(2)]
			public int SottOttPeriod2;

		[Parameter(MovMethod.VAR)]
			public MovMethod SottOttMethod2;

		[Parameter(MovMethod.VAR)]
			public MovMethod SottStosKMethod2;
		
		[Parameter(2)]
			public int SottOttPeriod3;

		[Parameter(MovMethod.VAR)]
			public MovMethod SottOttMethod3;

		[Parameter(MovMethod.VAR)]
			public MovMethod SottStosKMethod3;

		[Parameter(2)]
			public int SottOttPeriod4;	

		[Parameter(MovMethod.VAR)]
			public MovMethod SottOttMethod4;

		[Parameter(MovMethod.VAR)]
			public MovMethod SottStosKMethod4;

		[Parameter(MovMethod.VAR)]
			public MovMethod OttMovMethod1;

		[Parameter(true)]
			public bool OttSupportLine1;

		[Parameter(false)]
			public bool IsReduceOnly1;

		[Parameter(CryptoLeverageType.Isolated)]
			public CryptoLeverageType LeverageType1;

		[Parameter(false)]
			public bool IsReduceOnly2;

		[Parameter(10)]
			public decimal Leverage2;
		
		[Parameter(10)]
			public decimal Leverage5;
			
		[Parameter(10)]
			public decimal Leverage8;
		
		[Parameter(10)]
			public decimal Leverage11;

		[Parameter(false)]
			public bool IsReduceOnly3;

		[Parameter(false)]
			public bool IsReduceOnly4;

		[Parameter(CryptoLeverageType.Isolated)]
			public CryptoLeverageType LeverageType4;

		[Parameter(false)]
			public bool IsReduceOnly5;

		[Parameter(false)]
			public bool IsReduceOnly6;

		[Parameter(false)]
			public bool IsReduceOnly7;

		[Parameter(CryptoLeverageType.Isolated)]
			public CryptoLeverageType LeverageType7;

		[Parameter(false)]
			public bool IsReduceOnly8;

		[Parameter(false)]
			public bool IsReduceOnly9;

		[Parameter(false)]
			public bool IsReduceOnly10;

		[Parameter(CryptoLeverageType.Isolated)]
			public CryptoLeverageType LeverageType10;

		[Parameter(false)]
			public bool IsReduceOnly11;

		[Parameter(7)]
			public decimal OrderQuantity3;
		
		[Parameter(7)]
			public decimal OrderQuantity6;
		
		[Parameter(7)]
			public decimal OrderQuantity9;
		
		[Parameter(7)]
			public decimal OrderQuantity12;
		
		[Parameter(false)]
			public bool IsReduceOnly12;

		[Parameter(2.4)]
			public decimal ZararDurdurYuzdesi;
		

		TOTT tott;
		TOTT tott2;
		TOTT tott3;
		TOTT tott4;
		SOTT sott;
		SOTT sott2;
		SOTT sott3;
		SOTT sott4;
		MatriksIndicator HighLow;
		MatriksIndicator HighLow2;
		MatriksIndicator HighLow3;
		MatriksIndicator HighLow4;
		OTT ott;



		public override void OnInit()
		{

			tott = TOTTIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, TottPeriod1, TottOpt1, TottTwinOttCoef1, TottMovMethod1);
			tott2 = TOTTIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, TottPeriod2, TottOpt2, TottTwinOttCoef2, TottMovMethod2);
			tott3 = TOTTIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, TottPeriod3, TottOpt3, TottTwinOttCoef3, TottMovMethod3);
			tott4 = TOTTIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, TottPeriod4, TottOpt4, TottTwinOttCoef4, TottMovMethod4);
			sott = SOTTIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, SottPeriodK1, SottPeriodSlowK1, SottOttPeriod1, SottOttOpt1, SottOttMethod1, SottStosKMethod1);
			sott2 = SOTTIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, SottPeriodK2, SottPeriodSlowK2, SottOttPeriod2, SottOttOpt2, SottOttMethod2, SottStosKMethod2);
			sott3 = SOTTIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, SottPeriodK3, SottPeriodSlowK3, SottOttPeriod3, SottOttOpt3, SottOttMethod3, SottStosKMethod3);
			sott4 = SOTTIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, SottPeriodK4, SottPeriodSlowK4, SottOttPeriod4, SottOttOpt4, SottOttMethod4, SottStosKMethod4);
			HighLow = new HighLow();

			HighLow.SetIndicatorParameters("BarSayisi", HighlowBarSayisi1); RegisterUserIndicator(HighLow, Symbol1, SymbolPeriod1, OHLCType.Close, 5);

			HighLow2 = new HighLow();

			HighLow2.SetIndicatorParameters("BarSayisi", HighlowBarSayisi2); RegisterUserIndicator(HighLow2, Symbol1, SymbolPeriod1, OHLCType.Close, 5);

			HighLow3 = new HighLow();

			HighLow3.SetIndicatorParameters("BarSayisi", HighlowBarSayisi3); RegisterUserIndicator(HighLow3, Symbol1, SymbolPeriod1, OHLCType.Close, 5);

			HighLow4 = new HighLow();

			HighLow4.SetIndicatorParameters("BarSayisi", HighlowBarSayisi4); RegisterUserIndicator(HighLow4, Symbol1, SymbolPeriod1, OHLCType.Close, 5);

			ott = OTTIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, OttPeriod1, OttOpt1, OttMovMethod1, OttSupportLine1);

			SetLeverageType(Symbol1, LeverageType1);
			SetLeverage(Symbol1, Leverage2);
			SetLeverageType(Symbol1, LeverageType4);
			SetLeverage(Symbol1, Leverage5);
			SetLeverageType(Symbol1, LeverageType7);
			SetLeverage(Symbol1, Leverage8);
			SetLeverageType(Symbol1, LeverageType10);
			SetLeverage(Symbol1, Leverage11);

			SendOrderSequential(true, Side.Sell);
			WorkWithPermanentSignal(true);

			//Alttaki fonksiyon açıldıktan sonra parametre olarak verilen saniyede bir OnTimer fonksiyonu tetiklenir.
			// SetTimerInterval(3600);

			//Alttaki fonksiyon ile tanımlanan sembol ile ilgili haber geldiğinde OnNewsReceived fonksiyonu tetiklenir.
			//AddNewsSymbol(Symbol);

			//Alttaki fonksiyon ile tanımlanan anahtar kelime ile ilgili haber geldiğinde OnNewsReceived fonksiyonu tetiklenir.
			//AddNewsKeyword("KAP");
		}

		/// <summary>
		/// Init islemleri tamamlaninca, bardatalar kullanmaya hazir hale gelince bu fonksiyon tetiklenir. Data uzerinde bir defa yapilacak islemler icin kullanilir
		/// </summary>
		public override void OnInitCompleted()
		{

		}

		/// <summary>
		/// SetTimerInterval fonksiyonu ile belirtilen sürede bir bu fonksiyon tetiklenir.
		/// </summary>
		public override void OnTimer()
		{

		}

		/// <summary>
		/// AddNewsSymbol ve AddNewsKeyword ile haberlere kayit olunmuşsa bu fonksiyon tetiklenir.
		/// </summary>
		/// <param name="newsId">Gelen haberin id'si</param>
		/// <param name="relatedSymbols">Gelen haberin ilişkili sembolleri</param>
		public override void OnNewsReceived(int newsId, List<string> relatedSymbols)
		{

		}

		/// <summary>
		/// Eklenen sembollerin bardata'ları ve indikatorler güncellendikçe bu fonksiyon tetiklenir. 
		/// </summary>
		/// <param name="barData">Bardata ve hesaplanan gerçekleşen işleme ait detaylar</param>
		public override void OnDataUpdate(BarDataEventArgs barData)
		{
			var barData1 = GetBarData(Symbol1, SymbolPeriod1);
			var ohlcData1 = GetSelectedValueFromBarData(barData1, OHLCType.Low);
			var ohlcData2 = GetSelectedValueFromBarData(barData1, OHLCType.High);
			if (ott.Value[1][ott.CurrentIndex] < ott.Value[0][ott.CurrentIndex] && tott.Value[0][tott.CurrentIndex] < tott.Value[2][tott.CurrentIndex] && sott.Value[0][sott.CurrentIndex] < sott.Value[1][sott.CurrentIndex] && HighLow.Value[1][HighLow.CurrentIndex - 1] > ohlcData1)
			{
				SendMarketOrder(Symbol1, OrderQuantity3, OrderSide.Sell, includeAfterSession:false, isReduceOnly : IsReduceOnly3);
				StopLoss(Symbol1, SyntheticOrderPriceType.Percent, ZararDurdurYuzdesi);
			}
			if (ott.Value[1][ott.CurrentIndex] > ott.Value[0][ott.CurrentIndex] && tott2.Value[0][tott2.CurrentIndex] < tott2.Value[2][tott2.CurrentIndex] && sott2.Value[0][sott2.CurrentIndex] < sott2.Value[1][sott2.CurrentIndex] && HighLow2.Value[1][HighLow2.CurrentIndex - 1] > ohlcData1)
			{
				SendMarketOrder(Symbol1, OrderQuantity6, OrderSide.Sell, includeAfterSession:false, isReduceOnly : IsReduceOnly6);
				StopLoss(Symbol1, SyntheticOrderPriceType.Percent, ZararDurdurYuzdesi);
			}
			if (ott.Value[1][ott.CurrentIndex] < ott.Value[0][ott.CurrentIndex] && tott3.Value[0][tott3.CurrentIndex] > tott3.Value[1][tott3.CurrentIndex] && sott3.Value[0][sott3.CurrentIndex] > sott3.Value[1][sott3.CurrentIndex] && HighLow3.Value[0][HighLow3.CurrentIndex - 1] < ohlcData2)
			{
				SendMarketOrder(Symbol1, OrderQuantity9, OrderSide.Buy, includeAfterSession:false, isReduceOnly : IsReduceOnly9);
			}
			if (ott.Value[1][ott.CurrentIndex] > ott.Value[0][ott.CurrentIndex] && tott4.Value[0][tott4.CurrentIndex] > tott4.Value[1][tott4.CurrentIndex] && sott4.Value[0][sott4.CurrentIndex] > sott4.Value[1][sott4.CurrentIndex] && HighLow4.Value[0][HighLow4.CurrentIndex - 1] < ohlcData2)
			{
				SendMarketOrder(Symbol1, OrderQuantity12, OrderSide.Buy, includeAfterSession:false, isReduceOnly : IsReduceOnly12);
			}

		}

		/// <summary>
		/// Gönderilen emirlerin son durumu değiştikçe bu fonksiyon tetiklenir.
		/// </summary>
		/// <param name="barData">Emrin son durumu</param>
		public override void OnOrderUpdate(IOrder order)
		{
		}

		/// <summary>
		/// Strateji durdurulduğunda bu fonksiyon tetiklenir.
		/// </summary>
		public override void OnStopped()
		{
		}
	}
}

 

0 0

Merhabalar,

Sisteminizi aşağıdaki gibi düzenledik, kontrol sağlayabilir misiniz ?

***STRATEJİLERİ TEST/DENEME ORTAMINDA SINAMADAN VE SİZİN İSTEDİĞİNİZ ŞEKİLDE ÇALIŞTIĞINA EMİN OLMADAN GERÇEK ORTAMDA HİÇBİR ZAMAN ÇALIŞTIRMAYINIZ ***

using System;
using System.Collections.Generic;
using System.Linq;
using Matriks.AI;
using Matriks.Data.Symbol;
using Matriks.Engines;
using Matriks.Indicators;
using Matriks.Symbols;
using Matriks.AlgoTrader;
using Matriks.Trader.Core;
using Matriks.Trader.Core.Fields;
using Matriks.Trader.Core.TraderModels;
using Matriks.Lean.Algotrader.AlgoBase;
using Matriks.Lean.Algotrader.Models;
using Matriks.Lean.Algotrader.Trading;
namespace Matriks.Lean.Algotrader
{
	public class ShortSottTott2 : MatriksAlgo
	{
		[SymbolParameter("BTC_USDT_FBIN")]
			public string Symbol;
		[Parameter(SymbolPeriod.Min5)]
			public SymbolPeriod SymbolPeriod;
		[Parameter(0.003)]
			public decimal BuyOrderQuantity;
		[Parameter(0.003)]
			public decimal SellOrderQuantity;
		[Parameter(41)]
			public int TottPeriod1;

		[Parameter(1.1)]
			public decimal TottOpt1;

		[Parameter(501)]
			public int SottPeriodK1;

		[Parameter(201)]
			public int SottPeriodSlowK1;

		[Parameter(42)]
			public int TottPeriod2;

		[Parameter(1.2)]
			public decimal TottOpt2;

		[Parameter(502)]
			public int SottPeriodK2;

		[Parameter(202)]
			public int SottPeriodSlowK2;

		[Parameter(43)]
			public int TottPeriod3;

		[Parameter(1.3)]
			public decimal TottOpt3;

		[Parameter(503)]
			public int SottPeriodK3;

		[Parameter(203)]
			public int SottPeriodSlowK3;

		[Parameter(44)]
			public int TottPeriod4;

		[Parameter(1.4)]
			public decimal TottOpt4;

		[Parameter(504)]
			public int SottPeriodK4;

		[Parameter(204)]
			public int SottPeriodSlowK4;

		[Parameter(0.0008)]
			public decimal TottTwinOttCoef1;

		[Parameter(0.35)]
			public decimal SottOttOpt1;

		[Parameter(0.0008)]
			public decimal TottTwinOttCoef2;

		[Parameter(0.35)]
			public decimal SottOttOpt2;

		[Parameter(0.0008)]
			public decimal TottTwinOttCoef3;

		[Parameter(0.35)]
			public decimal SottOttOpt3;

		[Parameter(0.0008)]
			public decimal TottTwinOttCoef4;

		[Parameter(0.35)]
			public decimal SottOttOpt4;

		[Parameter(30)]
			public int OttPeriod1;

		[Parameter(7)]
			public decimal OttOpt1;

		[Parameter(21)]
			public int HighlowBarSayisi1;

		[Parameter(22)]
			public int HighlowBarSayisi2;

		[Parameter(23)]
			public int HighlowBarSayisi3;

		[Parameter(24)]
			public int HighlowBarSayisi4;

		[Parameter(MovMethod.VAR)]
			public MovMethod TottMovMethod1;

		[Parameter(MovMethod.VAR)]
			public MovMethod TottMovMethod2;

		[Parameter(MovMethod.VAR)]
			public MovMethod TottMovMethod3;

		[Parameter(MovMethod.VAR)]
			public MovMethod TottMovMethod4;

		[Parameter(2)]
			public int SottOttPeriod1;

		[Parameter(MovMethod.VAR)]
			public MovMethod SottOttMethod1;

		[Parameter(MovMethod.VAR)]
			public MovMethod SottStosKMethod1;

		[Parameter(2)]
			public int SottOttPeriod2;

		[Parameter(MovMethod.VAR)]
			public MovMethod SottOttMethod2;

		[Parameter(MovMethod.VAR)]
			public MovMethod SottStosKMethod2;

		[Parameter(2)]
			public int SottOttPeriod3;

		[Parameter(MovMethod.VAR)]
			public MovMethod SottOttMethod3;

		[Parameter(MovMethod.VAR)]
			public MovMethod SottStosKMethod3;

		[Parameter(2)]
			public int SottOttPeriod4;

		[Parameter(MovMethod.VAR)]
			public MovMethod SottOttMethod4;

		[Parameter(MovMethod.VAR)]
			public MovMethod SottStosKMethod4;

		[Parameter(MovMethod.VAR)]
			public MovMethod OttMovMethod1;

		[Parameter(true)]
			public bool OttSupportLine1;

		[Parameter(2.4)]
			public decimal ZararDurdurYuzdesi;

		TOTT tott;
		TOTT tott2;
		TOTT tott3;
		TOTT tott4;
		SOTT sott;
		SOTT sott2;
		SOTT sott3;
		SOTT sott4;
		MatriksIndicator HighLow;
		MatriksIndicator HighLow2;
		MatriksIndicator HighLow3;
		MatriksIndicator HighLow4;
		OTT ott;

		public override void OnInit()
		{
			AddSymbol(Symbol, SymbolPeriod);
			tott = TOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, TottPeriod1, TottOpt1, TottTwinOttCoef1, TottMovMethod1);
			tott2 = TOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, TottPeriod2, TottOpt2, TottTwinOttCoef2, TottMovMethod2);
			tott3 = TOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, TottPeriod3, TottOpt3, TottTwinOttCoef3, TottMovMethod3);
			tott4 = TOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, TottPeriod4, TottOpt4, TottTwinOttCoef4, TottMovMethod4);
			sott = SOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, SottPeriodK1, SottPeriodSlowK1, SottOttPeriod1, SottOttOpt1, SottOttMethod1, SottStosKMethod1);
			sott2 = SOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, SottPeriodK2, SottPeriodSlowK2, SottOttPeriod2, SottOttOpt2, SottOttMethod2, SottStosKMethod2);
			sott3 = SOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, SottPeriodK3, SottPeriodSlowK3, SottOttPeriod3, SottOttOpt3, SottOttMethod3, SottStosKMethod3);
			sott4 = SOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, SottPeriodK4, SottPeriodSlowK4, SottOttPeriod4, SottOttOpt4, SottOttMethod4, SottStosKMethod4);
			HighLow = new HighLow();

			HighLow.SetIndicatorParameters("BarSayisi", HighlowBarSayisi1); RegisterUserIndicator(HighLow, Symbol, SymbolPeriod, OHLCType.Close, 5);

			HighLow2 = new HighLow();

			HighLow2.SetIndicatorParameters("BarSayisi", HighlowBarSayisi2); RegisterUserIndicator(HighLow2, Symbol, SymbolPeriod, OHLCType.Close, 5);

			HighLow3 = new HighLow();

			HighLow3.SetIndicatorParameters("BarSayisi", HighlowBarSayisi3); RegisterUserIndicator(HighLow3, Symbol, SymbolPeriod, OHLCType.Close, 5);

			HighLow4 = new HighLow();

			HighLow4.SetIndicatorParameters("BarSayisi", HighlowBarSayisi4); RegisterUserIndicator(HighLow4, Symbol, SymbolPeriod, OHLCType.Close, 5);

			ott = OTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, OttPeriod1, OttOpt1, OttMovMethod1, OttSupportLine1);

			// Gerekli açığa satış
			WorkWithPermanentSignal(true);
			SendOrderSequential(true, HangiIslemleBaslasin);
			SendOrderSequentialForShort(true, Side.All);
			// #Gerekli açığa satış 

			// Gerekli - Kaldıraç
			SetLeverage(Symbol, Kaldirac); // kaldıraç oranı
			SetLeverageType(Symbol, true); // kaldıraç tipi - true isolated, false cross
			// #Gerekli - Kaldıraç 

			// Gerekli - Timestamp
			SetTimerInterval(1);
			// #Gerekli - Timestamp

		}

		public override void OnDataUpdate(BarDataEventArgs barData)
		{
			var barData1 = GetBarData(Symbol, SymbolPeriod);
			var ohlcData1 = GetSelectedValueFromBarData(barData1, OHLCType.Low);
			var ohlcData2 = GetSelectedValueFromBarData(barData1, OHLCType.High);
			if (ott.Value[1][ott.CurrentIndex] < ott.Value[0][ott.CurrentIndex] && tott.Value[0][tott.CurrentIndex] < tott.Value[2][tott.CurrentIndex] && sott.Value[0][sott.CurrentIndex] < sott.Value[1][sott.CurrentIndex] && HighLow.Value[1][HighLow.CurrentIndex - 1] > ohlcData1)
			{
				// Gerekli açığa satış
				FX_Satis(Symbol, BuyOrderQuantity);

				// #Gerekli açığa satış
			}

			if (ott.Value[1][ott.CurrentIndex] > ott.Value[0][ott.CurrentIndex] && tott2.Value[0][tott2.CurrentIndex] < tott2.Value[2][tott2.CurrentIndex] && sott2.Value[0][sott2.CurrentIndex] < sott2.Value[1][sott2.CurrentIndex] && HighLow2.Value[1][HighLow2.CurrentIndex - 1] > ohlcData1)
			{
				// Gerekli açığa satış
				FX_Satis(Symbol, SellOrderQuantity);

				// #Gerekli açığa satış
			}

			if (ott.Value[1][ott.CurrentIndex] < ott.Value[0][ott.CurrentIndex] && tott3.Value[0][tott3.CurrentIndex] > tott3.Value[1][tott3.CurrentIndex] && sott3.Value[0][sott3.CurrentIndex] > sott3.Value[1][sott3.CurrentIndex] && HighLow3.Value[0][HighLow3.CurrentIndex - 1] < ohlcData2)
			{
				// Gerekli açığa satış
				FX_Alis(Symbol, SellOrderQuantity);

				// #Gerekli açığa satış
			}

			if (ott.Value[1][ott.CurrentIndex] > ott.Value[0][ott.CurrentIndex] && tott4.Value[0][tott4.CurrentIndex] > tott4.Value[1][tott4.CurrentIndex] && sott4.Value[0][sott4.CurrentIndex] > sott4.Value[1][sott4.CurrentIndex] && HighLow4.Value[0][HighLow4.CurrentIndex - 1] < ohlcData2)
			{
				// Gerekli açığa satış
				FX_Alis(Symbol, SellOrderQuantity);

				// #Gerekli açığa satış
			}
		}

		// Gerekli açığa satış
		[Parameter(3)]
			public int Kaldirac;
		[Parameter(true)]
			public bool AcigaSatisYapilsin;
		[Parameter(false)]
			public bool AksamSeansiniDahilEt;
		[Parameter(Side.All)]
			public Side HangiIslemleBaslasin;

		public void FX_Alis(string Symbol, decimal quantity)
		{
			if (LastOrderSide.Obj != Side.Buy)
			{
				var _quantity = (LastOrderSide.Obj == Side.All || !AcigaSatisYapilsin || sentetikEmirdenMI) ? quantity:(LastOrderSideForShort.Obj == Side.All) ? quantity:quantity * 2; SendMarketOrder(Symbol, _quantity, OrderSide.Buy, includeAfterSession:AksamSeansiniDahilEt);
				Debug("Alış emri gönderildi.[ " + _quantity + " adet ]");
				LastOrderSideForShort = LastOrderSide;
				sentetikEmirdenMI = false;
			}
		}

		public void FX_Satis(string Symbol, decimal quantity)
		{
			if (LastOrderSide.Obj != Side.Sell)
			{
				var _quantity = (LastOrderSide.Obj == Side.All || !AcigaSatisYapilsin || sentetikEmirdenMI) ? quantity:(LastOrderSideForShort.Obj == Side.All) ? quantity:quantity * 2; SendMarketOrder(Symbol, _quantity, OrderSide.Sell, includeAfterSession:AksamSeansiniDahilEt);
				Debug("Satış emri gönderildi.[ " + _quantity + " adet ]");
				LastOrderSideForShort = LastOrderSide;
				sentetikEmirdenMI = false;
				StopLoss(Symbol, SyntheticOrderPriceType.Percent, ZararDurdurYuzdesi);
			}
		}

		bool sentetikEmirdenMI = false;

		public override void OnSyntheticOrderTriggered(SyntheticAlgoOrder sOrder)
		{
			if (sOrder.EnableOrderSending)
			{
				if (AcigaSatisYapilsin)
				{
					LastOrderSide.Obj = Side.All;
					sentetikEmirdenMI = true;
				} Debug("Sentetik emir tetiklendi");
			}
		}
		// #Gerekli açığa satış 

		// Gerekli - Timestamp
		public class OrderListTimestamp
		{
			public string ID;
			public string Symbol;
			public decimal Adet;
			public decimal Fiyat;
			public OrdType EmirTipi;
			public OrderSide orderSide;
			public string EmirYonu;
			public DateTime TetiklenmeZamani;
			public int Sayac;
			public bool AktifMI;
		}

		Dictionary<string, OrderListTimestamp> timestampDict = new Dictionary<string, OrderListTimestamp>();

		[Parameter(3)]
			public int AyniEmirKacSeferGonderilsin;
		[Parameter(10)]
			public int KacSaniyeSonraTekrarGonderilsin;

		string orderIDTimestamp = string.Empty;

		// #Gerekli
		public override void OnTimer()
		{
			// Gerekli - Timestamp
			var tutt = timestampDict.Where(x => x.Value.AktifMI == true && DateTime.Now >= x.Value.TetiklenmeZamani);

			if (tutt.Count() >0)
			{
				foreach (var deger in tutt)
				{
					LastOrderSide.Obj = deger.Value.orderSide == OrderSide.Buy? Side.Sell:Side.Buy;

					if (deger.Value.EmirTipi.Obj == OrdType.Limit)
					{
						orderIDTimestamp = SendLimitOrder(deger.Value.Symbol, deger.Value.Adet, deger.Value.orderSide, deger.Value.Fiyat);
						Debug(deger.Value.EmirYonu + " emri tekrar gönderildi.");
					}
					else if (deger.Value.EmirTipi.Obj == OrdType.Market)
					{
						orderIDTimestamp = SendMarketOrder(deger.Value.Symbol, deger.Value.Adet, deger.Value.orderSide);
						Debug(deger.Value.EmirYonu + " emri tekrar gönderildi.");
					}
					deger.Value.ID = orderIDTimestamp;
					deger.Value.AktifMI = false;
					timestampDict[orderIDTimestamp] = deger.Value;
					timestampDict.Remove(deger.Key);
				}
			}

			// #Gerekli - Timestamp
		}

		public override void OnOrderUpdate(IOrder order)
		{
			// Gerekli - Timestamp
			if (order.OrdStatus.Obj == OrdStatus.Filled)
			{
				if (timestampDict.ContainsKey(order.CliOrdID))
				{
					timestampDict.Remove(order.CliOrdID);
					Debug("Timestamp h
0 0
Merhaba, kodun son kısmında eksiklik var, lütfen düzeltir misiniz? Teşekkürler,
Hoş geldiniz, Matriks Destek Platformu sizlere sorularınızın hızlıca cevaplanması için bir ortam sağlar. Sorduğunuz ve cevapladığınız soruların ve yorumlarınızın aldığı oylar üzerinden puan kazanırsınız. Puan sistemine bağlı kampanyamızla ücretsiz kullanım avantajlarından faydalanabilirsiniz.



7,509 soru
7,511 cevap
4,405 yorum
8,718 kullanıcı