I have a simple strategy with 1 position for all entries. I find that the trailing stop doesn't work some times in live sim. Appreciate any help.
protected override void OnStateChange()
{
if (State == State.Configure)
{
SetTrailStop(CalculationMode.Ticks, 30);
}
}
protected override void OnBarUpdate()
{
if (CurrentBars[0] < 1)
return;
if <Longcondition>
{
EnterLong(Convert.ToInt32(DefaultQuantity), @"GoLong ");
}
if <Shortcondition>
{
EnterShort(Convert.ToInt32(DefaultQuantity), @"GoShort");
}
}
Basically, if a long or short condition is met, an order is placed with a trail stop. The order gets stopped either by a trailing stop or until opposite condition is met, in which case an order is placed in the opposite direction with a trailing again (whichever occurs first).
This works perfectly fine in Strategy Analyzer.
But, in live sim, I find that the trailing stop doesn't work for some orders and the trade goes on until opposite condition is met and trade gets placed in opposite direction. Any idea how I could resolve this?
Thanks
Comment