In realtime trading I need to use this:
if (BarsInProgress==0 || BarsInProgress==1 || BarsInProgress ==2 || BarsInProgress == 3) && (BarsSinceExit(0,"LongLimit", 0) >= 15) || BarsSinceExit(0,"LongLimit", 0) == -1 )
but in backtesting, the basinprogress doesn't seem to work right, as it seems to take orders in the other timeframes. It should wait 15 minutes after exiting but might hit barsinprogress 2, which is a 3 minute timeframe so I get orders on that timeframe as well, only in backtesting.
Not sure I'm explaining this correctly, but this is the solution I've come up with to get proper backtesting results, as well has having the strategy run properly in realtime:
((Historical && BarsInProgress==0) || (!Historical && (BarsInProgress==0 || BarsInProgress==1 || BarsInProgress ==2 || BarsInProgress == 3)) && (BarsSinceExit(0,"LongLimit", 0) >= 15) || BarsSinceExit(0,"LongLimit", 0) == -1 )
Please respond if this doesn't make sense.
Comment