I'm working on a strategy that has a limit entry order and stoploss trailing indicator values. Historical trades seem to plot as they should, yet in realtime, the pending orders are cancelled every other bar and are not replaced with new orders though the conditions still remain true. How do I either modify the limit price to the new indicator value, or cancel and replace the order so that I always have an active order when the conditions are true?
protected override void OnBarUpdate()
{
if (CurrentBars[0] < 51)
return;
// Set 1
if (EMA1[0] > EMA2[0])
{
EnterLongLimit(10000, EMA(Close, 50)[0] + (TickSize * 10), "AverageBuy" + CurrentBar);
SetStopLoss(CalculationMode.Price, EMA(Close, 50)[0] - (TickSize * 100) );
}
Comment