RobotFX curates the best open-source MetaTrader code to inspire your trading automation.
What ideas is the code based on?
The strategy measures recent buying pressure using the signed body-to-range ratio of each candle: (Close - Open) / max(High - Low) . The average is calculated over the candles immediately preceding the signal candle. With the default settings, these are the seven closed candles before the signal; the signal candle itself is excluded.
A positive average indicates that bullish candle bodies dominated this measure over the selected window. The EA then looks for a bearish candle with a sufficiently large body and range, a close near its low, and a close below the preceding candle's open. ATR is taken from the closed signal candle and used for both signal qualification and stop-distance calculation.
Position sizing uses a fixed lot input. The strategy does not use grid entries, martingale sizing, trailing stops, or breakeven adjustments.
Trade the powerful Traders Dynamic Index strategy automatically with this dedicated TDI Expert Advisor. More details.
How can the indications be interpreted?
The EA evaluates the most recently closed M15 candle once, on the first available tick of a new bar. A sell setup requires all of the following conditions with the default inputs:
- The average signed body-to-range ratio of the seven candles before the signal is at least 0.30.
- The signal candle is bearish, with a body of at least 0.70 times ATR(14) and a total range of at least 0.90 times ATR(14).
- The signal closes within the bottom 25% of its range and strictly below the preceding candle's open.
Suitable Symbols and Timeframes
The intended research instrument is XAUUSD, including broker-specific gold names such as XAUUSDm. The EA uses the chart symbol rather than a hardcoded symbol name.
For evaluation, select the broker's gold symbol and M15 in the MT5 Strategy Tester, use real ticks, and check trading costs, contract specifications, and execution logs. Test on a demo account before considering live use. This is an educational research example; it does not establish future performance.
Complement community code with advanced automation from RobotFX.
79887