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

Aşağıdaki stratejinin Long Short yani 1/-1 şeklinde çalışması ve stoploss ile trailingstoploss içermesi için koda ne gibi eklemeler yapılmalı?

Forumda benzer soruların yanıtlarını okudum ancak cross fonksiyonu ile çalışıyordu o stratejiler.

Emirleri sıralı göndermeyi FALSE yaptığımda büyük küçük operatörü kullanıldığından sürekli Al Al Al Al Al şeklinde ilerliyor. Emirleri sıralı göndermeyi TRUE yaptığımda ise Long/Short yöntemi çalışmıyor.

Yardımlarınız için şimdiden teşekkürler.

using System;
using System.Collections.Generic;
using System.Linq;
using Matriks;
using Matriks.Data.Symbol;
using Matriks.Data.Tick;
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 Matriks.Enumeration;
using Matriks.IntermediaryInstitutionAnalysis.Enums;
using Newtonsoft.Json;

namespace Matriks.Lean.Algotrader
{
	public class MOM_HHVLLV_MOST_S : MatriksAlgo
	{
		[SymbolParameter("XU030")]
			public string Symbol1;
		[SymbolParameter("X30YVADE")]
			public string OrderSymbol1;
		[Parameter(SymbolPeriod.Min)]
			public SymbolPeriod SymbolPeriod1;
		[Parameter(Side.Sell)]
			public Side orderSide;
		[Parameter(30)]
			public int MomPeriod1;
		[Parameter(60)]
			public int MomPeriod2;
		[Parameter(120)]
			public int MomPeriod3;
		[Parameter(240)]
			public int MomPeriod4;
		[Parameter(480)]
			public int MomPeriod5;
		[Parameter(960)]
			public int MomPeriod6;
		[Parameter(22)]
			public int EmaPeriod1;
		[Parameter(2)]
			public decimal MostPercentage1;
		[Parameter(MovMethod.E)]
			public MovMethod MostMovMethod1;
		[Parameter(40)]
			public int HighesthighPeriod1;
		[Parameter(40)]
			public int LowestlowPeriod1;
		[Parameter(1)]
			public decimal OrderQuantity1;
		[Parameter(true)]
		public bool AcigaSatisYapilsin;

		MOM mom;
		MOM mom2;
		MOM mom3;
		MOM mom4;
		MOM mom5;
		MOM mom6;
		EMA ema;
		MOST most;
		HighestHigh highestHigh;
		LowestLow lowestLow;

		int firstRun = 0;
		int realPosition = 0;

		public override void OnInit()
		{
			AddSymbol(OrderSymbol1, SymbolPeriod1);
			mom = MOMIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, MomPeriod1);
			mom2 = MOMIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, MomPeriod2);
			mom3 = MOMIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, MomPeriod3);
			mom4 = MOMIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, MomPeriod4);
			mom5 = MOMIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, MomPeriod5);
			mom6 = MOMIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, MomPeriod6);
			ema = EMAIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, EmaPeriod1);
			most = MOSTIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, EmaPeriod1, MostPercentage1, MostMovMethod1);
			highestHigh = HighestHighIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, HighesthighPeriod1);
			lowestLow = LowestLowIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, LowestlowPeriod1);

			SendOrderSequential(false, AcigaSatisYapilsin);
			WorkWithPermanentSignal(true);
			
		}

		public override void OnInitCompleted()
		{

		}

		public override void OnTimer()
		{

		}

		public override void OnNewsReceived(int newsId, List<string> relatedSymbols)
		{

		}

		public override void OnDataUpdate(BarDataEventArgs barData)
		{
			var barData1 = GetBarData(Symbol1, SymbolPeriod1);
			var ohlcData1 = GetSelectedValueFromBarData(barData1, OHLCType.High);
			var ohlcData2 = GetSelectedValueFromBarData(barData1, OHLCType.Low);
			int AlToplam = 0;

			if (mom.Value[0][mom.CurrentIndex] > 100.4m) AlToplam++;
			if (mom2.Value[0][mom2.CurrentIndex] > 100.4m) AlToplam++;
			if (mom3.Value[0][mom3.CurrentIndex] > 100.4m) AlToplam++;
			if (mom4.Value[0][mom4.CurrentIndex] > 100.4m) AlToplam++;
			if (mom5.Value[0][mom5.CurrentIndex] > 100.4m) AlToplam++;
			if (mom6.Value[0][mom6.CurrentIndex] > 100.4m) AlToplam++;
			if (AlToplam >= 3 && ema.Value[0][ema.CurrentIndex] > most.Value[0][most.CurrentIndex] && highestHigh.Value[0][highestHigh.CurrentIndex - 1] < ohlcData1)
			{
				if (firstRun == 0 || !AcigaSatisYapilsin)
				{
					SendMarketOrder(OrderSymbol1, OrderQuantity1, OrderSide.Buy, includeAfterSession:true);
					firstRun = 1;
				}
				else
				{
					SendMarketOrder(OrderSymbol1, OrderQuantity1 * 2, OrderSide.Buy, includeAfterSession:true);
				}

				if (mom.Value[0][mom.CurrentIndex] < 99.6m) AlToplam--;
				if (mom2.Value[0][mom2.CurrentIndex] < 99.6m) AlToplam--;
				if (mom3.Value[0][mom3.CurrentIndex] < 99.6m) AlToplam--;
				if (mom4.Value[0][mom4.CurrentIndex] < 99.6m) AlToplam--;
				if (mom5.Value[0][mom5.CurrentIndex] < 99.6m) AlToplam--;
				if (mom6.Value[0][mom6.CurrentIndex] < 99.6m) AlToplam--;
				if (AlToplam <= 3 && ema.Value[0][ema.CurrentIndex] < most.Value[0][most.CurrentIndex] && lowestLow.Value[0][lowestLow.CurrentIndex - 1] > ohlcData2)
				{
					if (firstRun == 0 || !AcigaSatisYapilsin)
					{
						SendMarketOrder(OrderSymbol1, OrderQuantity1, OrderSide.Sell, includeAfterSession:true);
					}
					else
					{
						SendMarketOrder(OrderSymbol1, OrderQuantity1 * 2, OrderSide.Sell, includeAfterSession:true);
						firstRun = 1;
					}
				}
			}
		}

		public override void OnOrderUpdate(IOrder order)
		{

		}

		public override void OnStopped()
		{
		}
	}
}

 

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

Bu soruya cevap vermek için lütfen giriş yapınız veya kayıt olunuz.

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.



8,391 soru
8,345 cevap
4,713 yorum
18,044 kullanıcı