Strategy Yazımında TrailingStopLoss
- Soruldu
- Kategori
- Algoritmik Trading
- Görüntülenme
- 88 görüntülenme
- Durum
- Cevaplandı
Aşağıdaki stratejide TrailingStopLoss(Symbol1, SyntheticOrderPriceType.Percent, StopLevel1, includeAfterSession:false)'i tek tek kullandığımda aynı sonuçları veriyor ama iki yerde de kullandığım zaman farklı sonuçlar veriyor arasında ki fark nedir?
public override void OnDataUpdate(BarDataEventArgs barData)
{
if (mov.Value[0][mov.CurrentIndex] > mov2.Value[0][mov2.CurrentIndex] && ott.Value[1][ott.CurrentIndex] > ott.Value[0][ott.CurrentIndex])
{
SendMarketOrder(Symbol1, OrderQuantity1, OrderSide.Buy, includeAfterSession:false);
//TrailingStopLoss(Symbol1, SyntheticOrderPriceType.Percent, StopLevel1, includeAfterSession:false);
}
if (mov.Value[0][mov.CurrentIndex] < mov2.Value[0][mov2.CurrentIndex] && ott.Value[1][ott.CurrentIndex] < ott.Value[0][ott.CurrentIndex])
{
SendMarketOrder(Symbol1, OrderQuantity1, OrderSide.Sell, includeAfterSession:false);
TrailingStopLoss(Symbol1, SyntheticOrderPriceType.Percent, StopLevel1, includeAfterSession:false);
}
}
public override void OnDataUpdate(BarDataEventArgs barData)
{
if (mov.Value[0][mov.CurrentIndex] > mov2.Value[0][mov2.CurrentIndex] && ott.Value[1][ott.CurrentIndex] > ott.Value[0][ott.CurrentIndex])
{
SendMarketOrder(Symbol1, OrderQuantity1, OrderSide.Buy, includeAfterSession:false);
TrailingStopLoss(Symbol1, SyntheticOrderPriceType.Percent, StopLevel1, includeAfterSession:false);
}
if (mov.Value[0][mov.CurrentIndex] < mov2.Value[0][mov2.CurrentIndex] && ott.Value[1][ott.CurrentIndex] < ott.Value[0][ott.CurrentIndex])
{
SendMarketOrder(Symbol1, OrderQuantity1, OrderSide.Sell, includeAfterSession:false);
TrailingStopLoss(Symbol1, SyntheticOrderPriceType.Percent, StopLevel1, includeAfterSession:false);
}
}
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 emaott : MatriksAlgo
{
[SymbolParameter("GARAN")]
public string Symbol1;
[Parameter(SymbolPeriod.Min)]
public SymbolPeriod SymbolPeriod1;
[Parameter(Side.Buy)]
public Side orderSide;
[Parameter(5)]
public int MovPeriod1;
[Parameter(MovMethod.E)]
public MovMethod MovMovMethod1;
[Parameter(55)]
public int MovPeriod2;
[Parameter(MovMethod.E)]
public MovMethod MovMovMethod2;
[Parameter(2)]
public int OttPeriod1;
[Parameter(1.4)]
public decimal OttOpt1;
[Parameter(MovMethod.VAR)]
public MovMethod OttMovMethod1;
[Parameter(true)]
public bool OttSupportLine1;
[Parameter(1)]
public decimal OrderQuantity1;
[Parameter(1)]
public decimal OrderQuantity2;
[Parameter(1)]
public decimal StopLevel1;
MOV mov;
MOV mov2;
OTT ott;
public override void OnInit()
{
mov = MOVIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, MovPeriod1, MovMovMethod1);
mov2 = MOVIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, MovPeriod2, MovMovMethod2);
ott = OTTIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, OttPeriod1, OttOpt1, OttMovMethod1, OttSupportLine1);
SendOrderSequential(true, orderSide);
WorkWithPermanentSignal(true);
}
public override void OnDataUpdate(BarDataEventArgs barData)
{
if (mov.Value[0][mov.CurrentIndex] > mov2.Value[0][mov2.CurrentIndex] && ott.Value[1][ott.CurrentIndex] > ott.Value[0][ott.CurrentIndex])
{
SendMarketOrder(Symbol1, OrderQuantity1, OrderSide.Buy, includeAfterSession:false);
//TrailingStopLoss(Symbol1, SyntheticOrderPriceType.Percent, StopLevel1, includeAfterSession:false);
}
if (mov.Value[0][mov.CurrentIndex] < mov2.Value[0][mov2.CurrentIndex] && ott.Value[1][ott.CurrentIndex] < ott.Value[0][ott.CurrentIndex])
{
SendMarketOrder(Symbol1, OrderQuantity1, OrderSide.Sell, includeAfterSession:false);
TrailingStopLoss(Symbol1, SyntheticOrderPriceType.Percent, StopLevel1, includeAfterSession:false);
}
}
public override void OnOrderUpdate(IOrder order){}
public override void OnStopped(){}
public override void OnInitCompleted(){}
public override void OnTimer(){ }
public override void OnNewsReceived(int newsId, List<string> relatedSymbols){}
}
}

