Look from NOW to the PAST. This chart you can see - this is all past data which is available for calculations. The same with indicators. Everything you can see on the chart is represented as numeric values in MetaTrader and they are available in every moment.
EA works on every tick - when a new tick comes, you check something and do something if needed.
- Check condition(s)
- Do action(s)
To get the value of the Nth candle from the past, there is a Candle ID parameter. If it is 10, this means that you work with the 10th candle from now to the past. That means you can check NOW what was happened in the PAST. There is no need to remember if some condition happens NOW and check that in the future, because this event (and many others) will be in the database.
In short. When working with conditions in some EA, the way to deal with them is from now to the past - when a tick comes, you can have a condition that can check something that happened in the past only by setting Candle ID parameter (aka Shift parameter in MQL).

At least in this form: