NT Support Super Dudes, I'd like to check if I'm encountering an unexpected issue of timing. My code is something like:
Calculate = Calculate.OnPriceChange;
OnBarUpdate()
if (entryOrder = null and some condition) entryorder = EnterLong()
if (entryOrder != null and some condition) entryorder = ExitLong()
OnOrderUpdate()
if (Order.IsTerminalState(order.OrderState)) entryOrder = null;
else entryOrder = order;
When I run this in backtest, no problem. When I run on a live market, both the EnterLong and ExitLong get hit multiple times in a row, like 2-5 times. I'm guessing that's because, after the EnterLong or ExitLong is called, it takes a moment for the order execution. Therefore, the update to the entryOrder value is delayed. Essentially, I go through the loop again before entryOrder is updated, so I end up repeating under the previous conditions.
Would this seem right to you? If so, any thoughts on how to address?
Thanks,

Comment