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

Merhaba;

Hazır stratejiler içerisinde bulunan Fast Turtle stratejisi içerisinde "kontrat büyüklüğü" olan satıra manuel olarak bir rakam vermek değil de Kıvanç Hocanın yayınlamış olduğu ELIS indikatörünün vermiş olduğu değeri eklemek istiyorum. Backtest seçeneklerinde bana kontrat büyüklüğü değilde ELIS indikatörünün değerini gireyim 1-5 gibi. Bu mümkün müdür rica etsem?

Ekleme -1;

ELIS indikatörü kullanıcı indikatörleri içerisinde mevcut. Algoritma sihirbazından kopya çekerek eklemeye çalıştım fakat ;

error CS0103: Gears' adı geçerli bağlamda yok3414
error CS0246: Gears' türü veya ad alanı adı bulunamadı (bir using yönergeniz veya derleme başvurunuz mu eksik?)3511

hatalarını aldım.

Ekleme-2;

Yine kodlardan kopya çekerek ELIS indikatörünü eklemeyi başardım fakat ELIS değerini ne yaptıysam debug ekranına yazdıramadım. En azından algoritmanın çalışıp çalışmadığını ELIS indikatörü eklenemeden ve eklenmiş hali arasındaki fark ile çalıştığını gözlemleyebiliyorum.

Ekleme-3;

ELIS indikatörünü release_Fast_Turtle stratejisine eklemeyi başardım. Fakat işleyiş esnasında şöyle bir sorun var, örneğin;

Turtle 1. alış emrini verdiğinde ELIS 14,
Turtle 2. alış emrini verdiğinde ELIS 16,

if (highest_high_LONGENTRY != 0 && close > highest_high_LONGENTRY && realposition == 0 && PyramidCount == 0)
   {
    SendMarketOrder(Symbol, unitROUND, OrderSide.Buy); 
    LongEntryPrice = close;
    PyramidCount++;
    Debug("Yukari kirilma gerceklesti, 1 unite ALIS emri gonderildi. ELIS: "+kontrat_buyuklugu);
    LongStopPrice = Math.Round((LongEntryPrice -2 * N), RoundTO);
    Debug($"LongStopPrice {LongStopPrice}, olarak olusturuldu.");
   }

   //LONG Adding Units
   if (realposition > 0 && close > LongEntryPrice + N / 2 && PyramidCount < MaxPyramid && PyramidCount != 0)
   {
     SendMarketOrder(Symbol, unitROUND, OrderSide.Buy);
    PyramidCount++;
    Debug($"Fiyat @{close}, son ALISTAN @{LongEntryPrice}, N/2 @{N/2} yukarida kapatti, {PyramidCount}. ALIS sayisina  ulasildi. ELIS: {kontrat_buyuklugu}");
    LongEntryPrice = close;
    LongStopPrice = Math.Round(LongStopPrice + N / 2, RoundTO);
    Debug($"LongStopPrice {LongStopPrice}, olarak GUNCELLENDI.");


Elis değeri mum hareketine göre değişiklik gösterdiği için unitROUND değeri de bir sonraki alış için farklı hesaplanmış oluyor. Burada ilk Alış emrinde baz almış olduğu elis değerini, bir sonraki alış emirleri için nasıl sabit tutabilirim. ?

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 release_Fast_Turtle : MatriksAlgo
	{
		[SymbolParameter("X30YVADE")]
		public string Symbol;
		[Parameter(SymbolPeriod.Day)]
		public SymbolPeriod SymbolPeriod;
		[Parameter(20)]
		public int numBarsHH_LONGENTRY;
		[Parameter(10)]
		public int numBarsLL_LONGEXIT;
		[Parameter(20)]
		public int numBarsLL_SHORTENTRY;
		[Parameter(10)]
		public int numBarsHH_SHORTEXIT;
		[Parameter(100000)]
		public decimal toplam_bakiye;
		[Parameter(1)]
		public decimal yuzde;
		[Parameter(2)]
		public int RoundTO;
		[Parameter(50)]
		public int ElisPeriod;
		[Parameter(ElisGear.Standard)]
		public ElisGear ElisElisGear;
		[Parameter(4)]
		public int MaxPyramid;


		public decimal realposition = 0;
		public decimal highest_high_LONGENTRY = 0;
		public decimal lowest_low_LONGEXIT = 0;
		public decimal lowest_low_SHORTENTRY = 0;
		public decimal highest_high_SHORTEXIT = 0;
		public decimal LongEntryPrice = 0;
		public decimal LongStopPrice = 0;
		public decimal ShortEntryPrice = 0;
		public decimal ShortStopPrice = 0;
		public int PyramidCount = 0;
		public bool completed = false;
		ATRE atre;
		ELIS elis;



		public override void OnInit()
		{

			atre = ATREIndicator(Symbol, SymbolPeriod, OHLCType.Close, 20);
			elis = ELISIndicator(Symbol, SymbolPeriod, OHLCType.Close, ElisPeriod, ElisElisGear);
			WorkWithPermanentSignal(false);
			SendOrderSequential(false);
		}

		public override void OnInitComplated()
		{

		}

		public override void OnDataUpdate(BarDataCurrentValues barDataCurrentValues)
		{
			/*
			Level Type Maximum Units
			1 Single Market 4 Units
			2 Closely Correlated Markets 6 Units
			3 Loosely Correlated Markets 10 Units
			4 Single Direction - Long or Short 12 Units
			*/
			var kontrat_buyuklugu = elis.CurrentValue;
			var barDataModel = GetBarData(Symbol, SymbolPeriod);
			var close = barDataCurrentValues.LastUpdate.Close;
			var N = atre.CurrentValue;
			var TLVOL = atre.CurrentValue * kontrat_buyuklugu;
			var unit = yuzde * 0.01m * toplam_bakiye / TLVOL;
			var unitROUND = (int) Math.Floor(unit);

			if (barDataCurrentValues.LastUpdate.IsNewBar == true)
			{
				if (!completed)
				{
					highest_high_LONGENTRY = HighestHigh(barDataModel, OHLCType.High, numBarsHH_LONGENTRY);
					lowest_low_LONGEXIT = LowestLow(barDataModel, OHLCType.Low, numBarsLL_LONGEXIT);
					lowest_low_SHORTENTRY = LowestLow(barDataModel, OHLCType.Low, numBarsLL_SHORTENTRY);
					highest_high_SHORTEXIT = HighestHigh(barDataModel, OHLCType.High, numBarsHH_SHORTEXIT);
					completed = true;
				}
				string header, line1;
				header = String.Format("{0,-10} {1,-10} {2,-10} {3,-10} {4,-25} {5,-10} {6,-25}", "ATR.E", "TLVOL", "unit", "unitROUND", "highest_high_LONGENTRY", "CLOSE", "lowest_low_SHORTENTRY");
				line1 = String.Format("{0,-10} {1,-10} {2,-10} {3,-10} {4,-25} {5,-10} {6,-25}", Math.Round(N, 2), Math.Round(TLVOL, 2), Math.Round(unit, 2), unitROUND, highest_high_LONGENTRY, close, lowest_low_SHORTENTRY);
				Debug(header);
				Debug(line1);
			}

			//LONG ENTRY. INITIAL ENTRY 20-day breakout (System 1)
			if (highest_high_LONGENTRY != 0 && close > highest_high_LONGENTRY && realposition == 0 && PyramidCount == 0)
			{
				SendMarketOrder(Symbol, unitROUND, OrderSide.Buy);
				LongEntryPrice = close;
				PyramidCount++;
				Debug("Yukari kirilma gerceklesti, 1 unite ALIS emri gonderildi. ELIS: "+kontrat_buyuklugu);
				LongStopPrice = Math.Round((LongEntryPrice -2 * N), RoundTO);
				Debug($"LongStopPrice {LongStopPrice}, olarak olusturuldu.");
			}

			//LONG Adding Units
			if (realposition > 0 && close > LongEntryPrice + N / 2 && PyramidCount < MaxPyramid && PyramidCount != 0)
			{
				SendMarketOrder(Symbol, unitROUND, OrderSide.Buy);
				PyramidCount++;
				Debug($"Fiyat @{close}, son ALISTAN @{LongEntryPrice}, N/2 @{N/2} yukarida kapatti, {PyramidCount}. ALIS sayisina  ulasildi. ELIS: {kontrat_buyuklugu}");
				LongEntryPrice = close;
				LongStopPrice = Math.Round(LongStopPrice + N / 2, RoundTO);
				Debug($"LongStopPrice {LongStopPrice}, olarak GUNCELLENDI.");

			}
			//Stop Placement
			if (realposition > 0 && close <= LongStopPrice && PyramidCount != 0)
			{
				SendMarketOrder(Symbol, realposition, OrderSide.Sell);
				Debug($"Fiyat @{close}, STOP fiyatina @{LongStopPrice} ulasti. {PyramidCount} unite UZUN pozisyon kapatildi.");
				LongEntryPrice = 0;
				PyramidCount = 0;
				LongStopPrice = 0;
			}

			//LONG EXIT
			if (realposition > 0 && close < lowest_low_LONGEXIT && PyramidCount != 0)
			{
				SendMarketOrder(Symbol, realposition, OrderSide.Sell);
				Debug($"Fiyat @{close}, CIKIS fiyatina @{lowest_low_LONGEXIT} ulasti. {PyramidCount} unite UZUN pozisyon kapatildi ({realposition}).");
				LongEntryPrice = 0;
				PyramidCount = 0;
				LongStopPrice = 0;
			}

			//==================================================================================================================//
			//SHORT ENTRY. INITIAL ENTRY 20-day breakout (System 1)
			if (lowest_low_SHORTENTRY != 0 && close < lowest_low_SHORTENTRY && realposition == 0 && PyramidCount == 0)
			{
				SendMarketOrder(Symbol, unitROUND, OrderSide.Sell);
				ShortEntryPrice = close;
				PyramidCount--;
				Debug("ASAGI kirilma gerceklesti, 1 unite SATIS emri gonderildi.ELIS: "+kontrat_buyuklugu);
				ShortStopPrice = Math.Round((ShortEntryPrice + 2 * N), RoundTO);
				Debug($"ShortStopPrice {ShortStopPrice}, olarak olusturuldu.");
			}

			//SHORT Adding Units
			if (realposition < 0 && close < ShortEntryPrice - N / 2 && PyramidCount > - MaxPyramid && PyramidCount != 0)
			{
				SendMarketOrder(Symbol, unitROUND, OrderSide.Sell);
				PyramidCount--;
				Debug($"Fiyat @{close}, son SATISTAN @{ShortEntryPrice}, N/2 @{N/2} asagida kapatti, {PyramidCount}. SATIS sayisina ulasildi.ELIS: {kontrat_buyuklugu}");
				ShortEntryPrice = close;
				ShortStopPrice = Math.Round(ShortStopPrice - N / 2, RoundTO);
				Debug($"ShortStopPrice {ShortStopPrice}, olarak GUNCELLENDI.");

			}
			//Stop Placement
			if (realposition < 0 && PyramidCount != 0 && close >= ShortStopPrice)
			{

				SendMarketOrder(Symbol, Math.Abs(realposition), OrderSide.Buy);
				Debug($"Fiyat @{close}, STOP fiyatina @{ShortStopPrice} ulasti. {PyramidCount} unite KISA pozisyon kapatildi.");
				ShortEntryPrice = 0;
				PyramidCount = 0;
				ShortStopPrice = 0;
			}

			//SHORT EXIT
			if (realposition < 0 && close > highest_high_SHORTEXIT && PyramidCount != 0)
			{
				SendMarketOrder(Symbol, Math.Abs(realposition), OrderSide.Buy);
				Debug($"Fiyat @{close}, KISA POZISYON CIKIS fiyatina @{highest_high_SHORTEXIT} ulasti. {PyramidCount} unite KISA pozisyon kapatildi ({realposition}).");
				ShortEntryPrice = 0;
				PyramidCount = 0;
				ShortStopPrice = 0;
			}

			highest_high_LONGENTRY = HighestHigh(barDataModel, OHLCType.High, numBarsHH_LONGENTRY);
			lowest_low_LONGEXIT = LowestLow(barDataModel, OHLCType.Low, numBarsLL_LONGEXIT);
			lowest_low_SHORTENTRY = LowestLow(barDataModel, OHLCType.Low, numBarsLL_SHORTENTRY);
			highest_high_SHORTEXIT = HighestHigh(barDataModel, OHLCType.High, numBarsHH_SHORTEXIT);
		}

		public override void OnOrderUpdate(IOrder order)
		{
			//Gercek zamanli pozisyon takibi
			if (order.OrdStatus.Obj == OrdStatus.Filled && order.Side.Obj == Side.Buy)
			{
				var positionChange = order.OrderQty;
				var LastExecPrice = order.LastPx;
				realposition += (int) positionChange;
				Debug("[ONORDERUPDATE]: Pozisyon = " + realposition + ", Fiyat = " + LastExecPrice);
			}

			if (order.OrdStatus.Obj == OrdStatus.Filled && order.Side.Obj == Side.Sell)
			{
				var positionChange = order.OrderQty;
				var LastExecPrice = order.LastPx;
				realposition -= (int) positionChange;
				Debug("[ONORDERUPDATE]: Pozisyon = " + realposition + ", Fiyat = " + LastExecPrice);
			}
		}
	}
}


Teşekkür ederim.

Algoritmik Trading kategorisinde (118 puan) tarafından | 339 kez görüntülendi
0 0
dostum stratejiden verim alabildiniz mi ?
0 0
Maalesef kriptoda kısa vadede hiç uygun değil, verim alamadım. uzun vadede belki kazandırabilirdi fakat onu da denemedim.

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.



7,571 soru
7,575 cevap
4,427 yorum
9,955 kullanıcı