0 beğenilme 0 beğenilmeme
302 kez görüntülendi
using System;

using System.Collections.Generic;

using System.Linq;

using Matriks.Data.Symbol;

using Matriks.Engines;

using System.Windows.Media;

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 emin32 : 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.

 

// 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("BOND_USDT_BIN")]

public string Symbol1;

 

[Parameter(SymbolPeriod.Min)]

public SymbolPeriod SymbolPeriod1;

 

[Parameter(20)]

public int OttPeriod1;

[Parameter(7)]

public decimal OttOpt1;

[Parameter(MovMethod.VAR)]

public MovMethod OttMovMethod1;

[Parameter(true)]

public bool OttSupportLine1;

 

 

[Parameter(10)]

public int TOTTPeriod;

[Parameter(0.56)]

public decimal TOTTOpt;

[Parameter(0.0008d)]

public decimal TwinOttCoef;

[Parameter(MovMethod.Variable)]

public MovMethod TottMovMethod;

 

 

 

[Parameter(2)]

public int TOTTPeriod2;

[Parameter(0.5)]

public decimal TOTTOpt2;

[Parameter(0.0005d)]

public decimal TwinOttCoef2;

[Parameter(MovMethod.Variable)]

public MovMethod TottMovMethod2;

 

 

[Parameter(20)]

public int HighesthighPeriod;

 

 

 

[Parameter(50)]

public int StochasticslowPeriodK1;

[Parameter(2)]

public int StochasticslowPeriodD1;

[Parameter(20)]

public int StochasticslowPeriodSlowK1;

[Parameter(MovMethod.E)]

public MovMethod StochasticslowMovMethod1;

 

[Parameter(20)]

public int StochasticslowPeriodK2;

[Parameter(2)]

public int StochasticslowPeriodD2;

[Parameter(20)]

public int StochasticslowPeriodSlowK2;

[Parameter(MovMethod.E)]

public MovMethod StochasticslowMovMethod2;

 

 

[Parameter(10)]

public decimal OrderQuantity1;

 

[Parameter(5)]

public decimal izsuren;

 

OTT ott;

TOTT tott;

TOTT tott2;

 

HighestHigh HHV;

StochasticSlow stochasticSlow;

StochasticSlow stochasticSlow2;

 

public override void OnInit()

{

 

 

AddSymbol(Symbol1, SymbolPeriod1);

 

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

tott = TOTTIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, TOTTPeriod, TOTTOpt, TwinOttCoef, TottMovMethod);

tott2 = TOTTIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, TOTTPeriod2, TOTTOpt2, TwinOttCoef2, TottMovMethod2);

stochasticSlow = StochasticSlowIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, StochasticslowPeriodK1, StochasticslowPeriodD1, StochasticslowPeriodSlowK1, StochasticslowMovMethod1);

stochasticSlow2 = StochasticSlowIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, StochasticslowPeriodK2, StochasticslowPeriodD2, StochasticslowPeriodSlowK2, StochasticslowMovMethod2);

HHV = HighestHighIndicator(Symbol1, SymbolPeriod1, 20);

 

SendOrderSequential(true, Side.Buy);

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>

/// 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 close = GetSelectedValueFromBarData(barData1, OHLCType.Close);

var h = GetSelectedValueFromBarData(barData1, OHLCType.High);

 

if (ott.Value[1][ott.CurrentIndex] > ott.Value[0][ott.CurrentIndex]

&& tott.Value[0][tott.CurrentIndex] > tott.Value[1][tott.CurrentIndex]

&& tott2.Value[0][tott2.CurrentIndex] > tott2.Value[2][tott2.CurrentIndex]

&& stochasticSlow.Value[0][stochasticSlow.CurrentIndex] > stochasticSlow.Value[1][stochasticSlow.CurrentIndex]

&& h > HHV.Value[0][HHV.CurrentIndex -1])

{

SendMarketOrder(Symbol1, OrderQuantity1, OrderSide.Buy, includeAfterSession:false);

//TrailingStopLoss(Symbol1, SyntheticOrderPriceType.Percent, izsuren);

Debug("Alış Emri Gönderildi.");

}

if (tott2.Value[0][tott2.CurrentIndex] < tott2.Value[1][tott2.CurrentIndex]

&& stochasticSlow2.Value[0][stochasticSlow2.CurrentIndex] < stochasticSlow2.Value[1][stochasticSlow2.CurrentIndex])

{

SendMarketOrder(Symbol1, OrderQuantity1, OrderSide.Sell, includeAfterSession:false);

Debug("Satış Emri Gönderildi.");

}

 

}

 

 

 

/// <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)

{

if (order.OrdStatus.Obj == OrdStatus.Filled)

{

 

}

}

 

/// <summary>

/// Strateji durdurulduğunda bu fonksiyon tetiklenir.

/// </summary>

public override void OnStopped()

{

}

}

}

//Binance  Sadece Long işlem yapıyorum.Bu stratejime izsuren stop ekleyebilerseniz çok memnun olurum..Özellikle tepe fiyatlardan dönüşlerde çalışmasını ve tabiki aldığım fiyatın altına düşüşlerde vereceğim tek yüzde ile sağlam bir şekilde çalışmasını istiyorum..
Algoritmik Trading kategorisinde (16 puan) tarafından | 302 kez görüntülendi

1 cevap

1 beğenilme 0 beğenilmeme

Merhabalar,

Aslında sisteminize iz süren stop eklemişsiniz fakat aynı satırı satış koşuluna da eklemeniz gerekiyor idi.

Satış koşuluna da iz süren stop eklendi. Bir de daha sağlıklı olsun diye son emir yönünü kontrol eden bir yapı ekledik.

Emir yönü kontrolü için aşağıdaki linki inceleyebilirsiniz.

https://destek.matriksdata.com/?qa=12386/matriks-iq-kar-al-y%C3%BCzdelik

using System;

using System.Collections.Generic;

using System.Linq;

using Matriks.Data.Symbol;

using Matriks.Engines;

using System.Windows.Media;

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 emin32 : 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.



		// 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("BOND_USDT_BIN")]

public string Symbol1;



		[Parameter(SymbolPeriod.Min)]

public SymbolPeriod SymbolPeriod1;



		[Parameter(20)]

public int OttPeriod1;

		[Parameter(7)]

public decimal OttOpt1;

		[Parameter(MovMethod.VAR)]

public MovMethod OttMovMethod1;

		[Parameter(true)]

public bool OttSupportLine1;





		[Parameter(10)]

public int TOTTPeriod;

		[Parameter(0.56)]

public decimal TOTTOpt;

		[Parameter(0.0008d)]

public decimal TwinOttCoef;

		[Parameter(MovMethod.Variable)]

public MovMethod TottMovMethod;







		[Parameter(2)]

public int TOTTPeriod2;

		[Parameter(0.5)]

public decimal TOTTOpt2;

		[Parameter(0.0005d)]

public decimal TwinOttCoef2;

		[Parameter(MovMethod.Variable)]

public MovMethod TottMovMethod2;





		[Parameter(20)]

public int HighesthighPeriod;







		[Parameter(50)]

public int StochasticslowPeriodK1;

		[Parameter(2)]

public int StochasticslowPeriodD1;

		[Parameter(20)]

public int StochasticslowPeriodSlowK1;

		[Parameter(MovMethod.E)]

public MovMethod StochasticslowMovMethod1;



		[Parameter(20)]

public int StochasticslowPeriodK2;

		[Parameter(2)]

public int StochasticslowPeriodD2;

		[Parameter(20)]

public int StochasticslowPeriodSlowK2;

		[Parameter(MovMethod.E)]

public MovMethod StochasticslowMovMethod2;





		[Parameter(10)]

public decimal OrderQuantity1;



		[Parameter(5)]

public decimal izsuren;



		OTT ott;

		TOTT tott;

		TOTT tott2;



		HighestHigh HHV;

		StochasticSlow stochasticSlow;

		StochasticSlow stochasticSlow2;



		public override void OnInit()
		{





			AddSymbol(Symbol1, SymbolPeriod1);



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

			tott = TOTTIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, TOTTPeriod, TOTTOpt, TwinOttCoef, TottMovMethod);

			tott2 = TOTTIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, TOTTPeriod2, TOTTOpt2, TwinOttCoef2, TottMovMethod2);

			stochasticSlow = StochasticSlowIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, StochasticslowPeriodK1, StochasticslowPeriodD1, StochasticslowPeriodSlowK1, StochasticslowMovMethod1);

			stochasticSlow2 = StochasticSlowIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, StochasticslowPeriodK2, StochasticslowPeriodD2, StochasticslowPeriodSlowK2, StochasticslowMovMethod2);

			HHV = HighestHighIndicator(Symbol1, SymbolPeriod1, 20);



			SendOrderSequential(true, Side.Buy);

			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>

		/// 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 close = GetSelectedValueFromBarData(barData1, OHLCType.Close);

			var h = GetSelectedValueFromBarData(barData1, OHLCType.High);



			if (ott.Value[1][ott.CurrentIndex] > ott.Value[0][ott.CurrentIndex]

&& tott.Value[0][tott.CurrentIndex] > tott.Value[1][tott.CurrentIndex]

&& tott2.Value[0][tott2.CurrentIndex] > tott2.Value[2][tott2.CurrentIndex]

&& stochasticSlow.Value[0][stochasticSlow.CurrentIndex] > stochasticSlow.Value[1][stochasticSlow.CurrentIndex]

&& h > HHV.Value[0][HHV.CurrentIndex -1]
				&& LastOrderSide.Obj!=Side.Buy)
			{

				SendMarketOrder(Symbol1, OrderQuantity1, OrderSide.Buy, includeAfterSession:false);

				TrailingStopLoss(Symbol1, SyntheticOrderPriceType.Percent, izsuren);

				Debug("Alış Emri Gönderildi.");

			}

			if (tott2.Value[0][tott2.CurrentIndex] < tott2.Value[1][tott2.CurrentIndex]

&& stochasticSlow2.Value[0][stochasticSlow2.CurrentIndex] < stochasticSlow2.Value[1][stochasticSlow2.CurrentIndex]
				&& LastOrderSide.Obj!=Side.Sell)
			{

				SendMarketOrder(Symbol1, OrderQuantity1, OrderSide.Sell, includeAfterSession:false);
				TrailingStopLoss(Symbol1, SyntheticOrderPriceType.Percent, izsuren);

				Debug("Satış Emri Gönderildi.");

			}



		}







		/// <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)
		{

			if (order.OrdStatus.Obj == OrdStatus.Filled)
			{



			}

		}



		/// <summary>

		/// Strateji durdurulduğunda bu fonksiyon tetiklenir.

		/// </summary>

		public override void OnStopped()
		{

		}

	}

}

İyi çalışmalar.

(11,069 puan) tarafından
0 0
Çok teşekkür ederim.Emeğinize sağlık.

Sağlıklı şekilde çalıştı.
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,511 soru
7,515 cevap
4,405 yorum
8,751 kullanıcı