Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Fractal - MetaTrader 4 Script | Forex Indicator Download - MT4/MT5 Resources - MetaTrader 5 Resources

author EAcpu | 5 reads | 0 comments |

Fractal - indicator for MetaTrader 4

Fractal - indicator for MetaTrader 4

Fractal - indicator for MetaTrader 4

Fractal - indicator for MetaTrader 4

If you find this metric useful, you can show your support for the GitHub repository and this article by giving it a star. You are more than welcome to leave a comment below this article to report bugs, or suggest any further improvements you may find useful. You can do the same by opening an issue on the GitHub repository. You can also contribute source code by issuing a pull request on the GitHub repository.

Run MetaTrader and navigate to your MetaTrader data folder by selecting "File" -> "Open Data Folder" from the menu bar. Copy Fractal-Utility.mqh into the MQL4\Includes folder, then copy Fractal-STF.mq4 and Fractal-MTF.mq4 into the MQL4\Indicators folder. The final step is to compile fractal-STF.mq4 and fractal-MTF.mq4 via the meta-editor to create fractal-STF.ex4 and fractal-MTF.ex4 , respectively. Now you should be able to use the Fractal-STF and Fractal-MTF indicators in the MetaTrader terminal. The only requirement for installation is to place both fractal-STF.mq4 and fractal-MTF.mq4 into the same directory, which can be any subdirectory MQL4\Indicators like MQL4\Indicators\Developed . Note that whenever you relocate compiled files to another directory, you should recompile them in that directory to make them work properly.

STF is the abbreviation for Single Time Frame. MTF is the abbreviation for Multiple Time Frame. Therefore, Fractal-STF is an indicator whose calculation involves only a single time frame, while Fractal-MTF is calculated using multiple time frames. Therefore, Fractal-STF is slightly faster than Fractal-MTF because it needs to perform fewer calculations. You can notice this fact when you want to switch between different time frames. For the current version, the algorithm used for Fractal-MTF is not optimized yet, I try to improve it in future updates for better performance. If you find the latency of Fractal-MTF annoying, and you don't use the multi-timeframe feature much, it might be wise to just use Fractal-STF.

There is a built-in fractal indicator in MT4/MT5 whose origins can be traced back to the famous Bill Williams. The main purpose of this indicator is to identify local extrema by comparing the high/low of a candle with the high/low of its neighboring candles to prove that it is an upper/lower fractal, a term coined by Williams, rather than a local maximum/minimum. Some other equivalent terms are swing highs/lows and tops/bottoms, which are used interchangeably among traders.

This indicator has the following advantages compared to the built-in MT4/MT5 indicators:

1. Williams believes that just like our middle finger, which is a fractal compared to two adjacent fingers, the radius of comparison should be selected as 2, which is the default value of the built-in fractal indicator in MT4/MT5. In this indicator, the user can select this neighborhood radius according to his wish. The advantage of this is that different degrees of extreme values ​​can be distinguished simultaneously on the chart, as shown below in Figure 1 .

2. The user can also select the shape of the symbols pointing to these extrema, allowing him/her to associate the extrema of each degree with a unique symbol for better visualization.

3. Users can specify the vertical distance between the arrow and the highest/lowest point of the candle to avoid overlap of symbols corresponding to different degrees of extreme values. The idea of ​​dynamically adjusting vertical distance was mainly inspired by tdbarnard's answer here . The main point to consider is that we want the pixel distance from the arrow (arrow offset) to be a constant value away from the high/low of the candle. However, this does not mean that equal price distances should also be constant. Indeed, as the chart scale changes, the price distance corresponding to the fixed pixel distance will also change, which requires dynamic distance adjustment. You can see the detailed implementation of this idea in the code.

4. Users can view higher timeframe fractals on lower timeframes, making it a Multi Timeframe (MTF) indicator. For example, the user can set the indicator time frame to D1 and choose the radius of the fractal to be 2. Next, if the user switches to the M15 timeframe, Fractals-MTF will mark those M15 bars whose highs/lows coincide with the highs/lows of the corresponding fractal on the D1 timeframe. Please note that the indicator timeframe should be greater than or equal to the attached chart timeframe. If the user selects an indicator time range that is smaller than the chart time range, the indicator uses the chart time range by default.

Fractal - indicator for MetaTrader 4

Figure 1 . Fractal with neighborhood radii of 2 and 5.

Fractal - indicator for MetaTrader 4

Figure 2. Input of the Fractal MTF indicator.


Attachment download

📎fractal-utilities.mqh (3.74 KB)

📎fractal-stf.mq4 (6.18 KB)

📎fractal-mtf.mq4 (7.31 KB)

Source: MQL5 #35575

Verification code Refresh