Watch how to download trading robots for free
Find us on Twitter!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Experts

Popular (1M views) 4 Hour Range Strategy coded and tested - expert for MetaTrader 4

Views:
180
Rating:
(1)
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

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:

Backtest report for MT5

Equity curve


StrategyTester in pips StrategyTester in pips

Tester statistics in pips with an early filter. This is how it should be done.

iVIDyA indicator for mt4 iVIDyA indicator for mt4

VIDyA is only available by default in mt5, here is it's mt4 equivalent. Note if using it with an EA call it using the iCustom() function.

Three Colors Three Colors

Example: Moving Average indicator filling by different colors

MACD Sample MACD Sample

Classical MACD Sample.