If NT tries to switch position (from Long to Short or vice versa) in a short duration bar (say 5 seconds), at least while trading on IB, then ALL Stop Loss and Target orders can be cancelled, thus leaving the new position unprotected.
I have even seen cases where the new position is double the size requested in the strategy.
I have also seen a case where NT closed the strategy (having detected some conflict condition), but did not close the unprotected position.
Steps to reproduce the problem:
1) Create a simple strategy called DontRunThisLive (no parameters) as below.
2) Run the strategy on a 5 second FX data series, against IB papertrade account.
3) Monitor the Orders in NT (& IB Portfolio tab).
You may find the majority of position changes work fine, but it will not take long before you see the following in IB:
Four bracket orders are visible at the same time, then all get cancelled. I assume this has something to do with the full set of actions not completing within the bar period. So if the new bracket orders dont become active before the five second bar completes, then they are being cancelled by something (NT on the start of new bar)?
This appears to indicate something defective in NT error handling in cases where bar completes before order changes requested in the bar have become active.
DontRunThisLive code:
This is simply designed to switch frequently between Long and Short positions, in theory always protected by Stop Loss and Target orders.
{
SetProfitTarget("S1", CalculationMode.Ticks, 15);
SetStopLoss("S1", CalculationMode.Ticks, 20, false);
SetProfitTarget("L1", CalculationMode.Ticks, 15);
SetStopLoss("L1", CalculationMode.Ticks, 20, false);
DefaultQuantity=100000;
TraceOrders=true;
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBar<10) return;
// Condition set 1
if (Close[0] > Open[0]
&& Low[0] > Low[1])
{
Print(string.Format("Should EnterLong with DefaultQuantity={0}, EntriesPerDirection={1}, EntryHandling={2}",DefaultQuantity,EntriesPerDirec tion,EntryHandling ));
EnterLong(DefaultQuantity, "L1");
}
// Condition set 2
if (Close[0] < Open[0]
&& High[0] < High[1])
{
Print(string.Format("Should EnterShort with DefaultQuantity={0}, EntriesPerDirection={1}, EntryHandling={2}",DefaultQuantity,EntriesPerDirec tion,EntryHandling));
EnterShort(DefaultQuantity, "S1");
}
}

Comment