-->

Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

Metatrader 5 Expert Advisor | Viral (1M+ views) 4 Hour Range Strategy coded and tested | MQL5 Community Release

New free code from MQL5: indicators, EAs, and scripts for traders.

Provided for educational purposes; not trading advice. Backtests on EURUSD under my conditions were unprofitable.

The strategy follows the following logic:

  1. First the strategy marks the high and the low of the first 4H candle, using the New york time zone.
  2. After the first 4H candle is formed the strategy waits for a 5 Minute candle to close outside the Range.
  3. If a 5 Minute candle closes above the High and then a 5 Minute candle closes back in the Range, there is a sell signal.
  4. If a 5 Minute candle closes below the Low and then a 5 Minute candle closes back in the Range, there is a buy signal.

There was one vague rule the strategy did not follow regarding the orderblock. To avoid trades after the price has overextended beyound the range, a time filter was introduced and if the price stayed above the high or below the low for more than 75 Minutes the trade is marked as invalid.

It is of utmost importance to specify your own broker's GMT offset times and the dates when the switching from Summer time to Winter time (and vica versa). Since this strategy is based on the New York local time, a single error in this can offset the whole strategy.

Here are the input parameters for the strategy:

  1. ServerGMTOffsetWinter: The GMT offset of the broker's server in winter time.
  2. ServerGMTOffsetSummer: The GMT offset of the broker's server in summer time. (Can be the same as Winter offset for brokers with fixed GMT offset)
  3. ServerSwitchToSummerMonth: The month when the broker switches to summer time zone.
  4. ServerSwitchToSummerDay: The day of month when the broker switches to summer time zone.
  5. ServerSwitchToWinterMonth: The month when the broker switches to winter time zone.
  6. ServerSwitchToWinterDay: The day of month when the broker switches to winter time zone.
  7. Lots: Lotsize

Here are the backtest results of the backtest for EURUSD:

Equity curve

Backtest report


Smooth out market noise with the Heiken Ashi Expert Advisor for MT4 and MT5. Reliable trend-following automation. Details here.

Build better strategies with RobotFX professional tools – check them out.

68082

Best MetaTrader Indicators + Profitable Expert Advisors