How can you backtest your strategy only within a specific time window on an intraday basis?
I'm testing a combination of MACD and BB on a timeframe of 1 minute. But I only want to enter a long or short position at UTC+2 between 10am and 1430 and 1600 and 2000 for CME listed futures. I want to exit any open position within X minutes outside of the entry window.
In a simplified way, my code currently looks like below:
++
longentry = crossover(macd, signal) and src <= lowerBB shortentry = crossunder(macd, signal) and src >= upperBB
longclose = crossunder(src, lowerBB) shortclose = crossover(src, upperBB)
if longentry strategy.entry("id=LONG", strategy.long)
if shortentry strategy.entry("id=SHORT", strategy.short)
++
Your assistance would be much appreciated.
Thanks and best regards,
Bas