I am working on a smiple strategy where if my entry condition is satisfied I open 2 orders on the high and low of the candle that just finished.
I use these as Order entries
private Order longOrder;
private Order shortOrder;
protected override void OnBarUpdate()
{
if(CurrentBar == 0)
return;
scenarios.Add(GetScenario());
//if(!IsSetup)
IsStratPattern();
}
private void IsStratPattern()
{
if(scenarios.Count<3)
return ;
if(scenarios[scenarios.Count-1] == "1")
{
IsSetup = true;
SetupTrade();
}
if(scenarios[scenarios.Count-1] == "3")
{
IsSetup = true;
SetupTrade();
}
}
private void SetupTrade()
{
longOrder = EnterLongStopMarket(High[0] + TickSize*1);
shortOrder = EnterShortStopMarket(Low[0] - TickSize*1);
}
protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
{
if(Position.MarketPosition == MarketPosition.Long)
{
CancelOrder(shortOrder);
longOrder = null;
shortOrder = null;
}
else if(Position.MarketPosition == MarketPosition.Short)
{
CancelOrder(longOrder);
longOrder = null;
shortOrder = null;
}
SetProfitTarget(CalculationMode.Ticks,10 );
SetStopLoss(CalculationMode.Ticks, 8);
};
Any idea why ?

Comment