I have coded a indicator that assignes a variable the value 500 when all my conditions are meet.
I have a automatic trading system (strategy) that have exactly the same conditions as the indicator, fullfilled conditions = BUY x contract.
But, the automatic trading system (strategy) executes the BUY one bar after the variable is 500, why?
The BUY should be executed at the same bar as the variable is 500? This is when I backtest, I have never tested this strategy in real life. Is it different then?
Your variable become 500 at the close (end) of the current bar, not at the open of the current bar!
Your automatic trading system (strategy) can’t guess that your variable will be equal to 500 before the end of the current bar…
Therefore your automatic trading system executes the BUY at the open of the next candle… (the bar that is next the one that is 500)
It is just normal and the same in backtest and in real life.