TraderKevin
Member
Hey guys and gals,
I've been backtesting a new strategy and for some reason my orders are not executing on the 1st bar after the conditions are satisfied, but instead skipping a bar and executing 2 bars after the event. What makes it stranger is that sometimes it executes like it normally does and buys/sells on the bar after the conditions are satisfied, but this is a small percentage of the time.
I've narrowed the script down to be extremely simple (pardon my hiding the key variables for confidentiality) for testing:
def x= if high("XYZ") >= # then 1 else 0;
def y= if low("XYZ") <= # then 1 else 0;
AddOrder(OrderType.BUY_AUTO, x== 1, close, 300, tickcolor = GetColor(1), arrowcolor = GetColor(1));
AddOrder(OrderType.SELL_AUTO, y== 1, close, 300, tickcolor = GetColor(2), arrowcolor = GetColor(2));
This is literally it... no offsets, nothing. Buy when x==1 it doesn't buy on the next bar, but the following. Anyone else experienced this or know what might be causing it?
I've been backtesting a new strategy and for some reason my orders are not executing on the 1st bar after the conditions are satisfied, but instead skipping a bar and executing 2 bars after the event. What makes it stranger is that sometimes it executes like it normally does and buys/sells on the bar after the conditions are satisfied, but this is a small percentage of the time.
I've narrowed the script down to be extremely simple (pardon my hiding the key variables for confidentiality) for testing:
def x= if high("XYZ") >= # then 1 else 0;
def y= if low("XYZ") <= # then 1 else 0;
AddOrder(OrderType.BUY_AUTO, x== 1, close, 300, tickcolor = GetColor(1), arrowcolor = GetColor(1));
AddOrder(OrderType.SELL_AUTO, y== 1, close, 300, tickcolor = GetColor(2), arrowcolor = GetColor(2));
This is literally it... no offsets, nothing. Buy when x==1 it doesn't buy on the next bar, but the following. Anyone else experienced this or know what might be causing it?