4-Hour Range Strategy: Coded and Tested

4-Hour Range Strategy: Coded and Tested
Download ALL MT4 experts (893)
YouTube Video Thumbnail



Similar MetaTrader Tools

4-Hour Range Strategy: Coded and Tested

Info

The 4-Hour Range Strategy: Coded and Tested is a Expert Advisor for MetaTrader 4 that this strategy is provided for educational purposes and is not trading advice. Backtests on EURUSD under specific conditions were unprofitable.

Usage

This tool is typically used for automated trading on major forex pairs and gold.

Platform

This Expert Advisor works exclusively on MetaTrader 4 (both build 600+ and newer versions).

Setup

Place the downloaded file in MQL4/Experts folder via File ? Open Data Folder in MetaTrader 4.


How to Install and Use 4-Hour Range Strategy: Coded and Tested

1. Installation: Open the "File" menu, select "Open Data Folder," navigate to MQL/Experts, paste your file, and restart the terminal.

2. Activation: Drag the EA from the Navigator onto a chart, ensure "Allow live trading" is checked in the Common tab, and verify the AutoTrading button is green.

3. Optimization: Right-click your chart, choose "Expert List," click "Properties" to adjust inputs, and save your preferred setup as a set file for future use.

4. Maintenance: Regularly check the "Experts" tab in the terminal window to monitor trade logs and potential execution errors.

Frequently Asked Questions

Q: Why is my EA not opening trades? A: Check the "AutoTrading" button, ensure "Allow live trading" is enabled, and verify your broker allows automated trading on your account type.

Q: Can I run multiple EAs on one chart? A: No, each chart can only host one active EA; however, you can open multiple charts for different currency pairs to run several EAs.

Q: What does the "smiley face" icon mean? A: A smiley face in the top-right corner of the chart indicates the EA is successfully running; a frowny face means it is disabled.

What this tool does

This strategy is provided for educational purposes and is not trading advice.

Typical Use Case

This Expert Advisor excels in automated trading and technical analysis on MetaTrader 4.

Compatible Platform & Setup

This Expert Advisor works on MetaTrader 4. Place the file in the MQL4/Experts folder and restart the terminal.

Description & Settings

Related: average range monitor (arm) - another powerful expert for MetaTrader 4 traders.

This strategy is provided for educational purposes and is not trading advice. Backtests on EURUSD under specific conditions were unprofitable.

Also recommended: Indicator and Expert Advisor for Range-Bound Market Entry - similar expert with strong performance on MetaTrader 4.


The strategy operates based on the following logic:

It first marks the high and low of the initial 4-hour candle using the New York time zone.

After the first 4-hour candle forms, the strategy waits for a 5-minute candle to close outside the range.

If a 5-minute candle closes above the high and then another 5-minute candle closes back within the range, a sell signal is generated.

Conversely, if a 5-minute candle closes below the low and then another 5-minute candle closes back within the range, a buy signal is triggered.

To avoid trades after the price has overextended beyond the range, a time filter is introduced. If the price stays above the high or below the low for more than 75 minutes, the trade is marked as invalid.

It is crucial to specify your broker's GMT offset times and the dates for switching between summer and winter time zones. As this strategy relies on New York local time, a single error in these settings can significantly impact its performance.

Here are the input parameters for the strategy:

- servergmtoffsetwinter: GMT offset of the broker's server in winter.

- servergmtoffsetsummer: GMT offset of the broker's server in summer. (Can be the same as winter offset for brokers with fixed GMT offsets)

- serverswitchtosummermonth: Month when the broker switches to summer time.

- serverswitchtosummerday: Day of the month for the summer time switch.

- serverswitchtowintermonth: Month when the broker switches to winter time.

- serverswitchtowinterday: Day of the month for the winter time switch.

- lots: Lot size

Below are the backtest results for EURUSD:

You may also like: Unseasonalised Average Trading Range and Forecast for Monthly Charts - excellent alternative for expert users on MetaTrader 4.

Source Code

#property copyright "RobotFX"
#property link "https://robotfx.org"
#property version   "1.01"
#property strict
extern int  ServerGMTOffsetWinter = 2;   // Server GMT offset in Winter time
extern int  ServerGMTOffsetSummer = 3;   // Server GMT offset in Summer time (can be the same as winter)
extern int  ServerSwitchToSummerMonth = 3;   // Month when broker's server switches to Summer time
extern int  ServerSwitchToSummerDay   = 1;   // Day of month when broker's server switches to Summer time
extern int  ServerSwitchToWinterMonth = 11;  // Month when broker's server switches to Winter time
extern int  ServerSwitchToWinterDay   = 1;   // Day of month when broker's server switches to Winter time

.......

Leave your opinion, ask a question, share some knowledge

⚠ Limitations & Risk Warning

  • This tool is provided for educational and testing purposes only.
  • Past performance does not guarantee future results.
  • Trading involves substantial risk of loss. Use on a demo account first.
  • Results may vary depending on market conditions, broker, and settings.
  • We recommend thorough backtesting and forward testing before using with real funds.
© ROBOTFX Free educational tools by RobotFX. Use entirely at your own risk; we are not liable for any financial losses incurred.