Comparing last order close time to amount of closed candles since order was closed
-
I am trying to test a re-entry option for my EA that places another trade if the previous trade was closed due to stop-loss at least 'x' candles ago, and if the current greater timeframe indicator is still in a specified state, and if the current price is still a certain level.
Problem Scenario:
Let's say the normal conditions require two MA's to crossover 1 candle ago. They bullishly do so and trigger a buy.
Price moves sharply lower and triggers stop-loss.
Price recovers and continues upwards, but I miss out on any profit because the conditions that triggered a buy in the first place have passed since the crossover now happened more than 1 candles ago.A possible solution to enjoy some of the profits are to re-renter a long position as long as certain conditions are met (for example, as long as a higher time pair of MA's still move bullishly and as long as the price is still above the slower MA)
2 Questions:
#1
I am not confident that I built the blocks correctly to accomplish this. Specifically, the "ticket <= ReEntry Candle" block.
Should this be >=? Is this even the correct approach?#2
The example I'm linking to assumes initialization of a M5 chart and uses the M15 chart as the higher timeframe reference. I haven't figured out how to set blocks to reference a constant setting's higher timeframe (can I just enter the minute integers in a constant like (1,15,60,240), and fxdreema will interpret that as (M1, M15, H1, H4)?shared link: https://fxdreema.com/shared/hFh8N23Gb
screenshot:

Thanks!
-
If you want to check how old is some trade, using pink blocks, there is a block "check age" which can be used and it feels more naturally.
If you want to create input parameter for the EA where you can select different timeframes, you can make it with data type ENUM_TIMEFRAMES. As a default value you can have PERIOD_M15, which is a predefind constant. Here is more info: https://www.mql5.com/en/docs/constants/chartconstants/enum_timeframes