FractalBest
Download scriptThis script is a custom visual tool designed for the MetaTrader platform to help traders identify specific price patterns known as "fractals" in real-time. Instead of cluttering the chart with complex data, it simplifies market behavior by highlighting key turning points where the price reaches a local peak or valley.
How the Logic Works
The core functionality of this tool relies on comparing the current price movements against a specific window of recent price bars. It looks for "pivot points" based on the following logic:
-
Identifying High Points (Upside Fractals): The script constantly monitors the highest prices over a five-bar period. If it detects that a specific peak is higher than the two candles immediately preceding it and the two candles immediately following it, it identifies this as a significant high point. When this condition is met, the tool places a visual marker (an arrow) on the chart to alert you to a potential resistance level or price ceiling.
-
Identifying Low Points (Downside Fractals): Similarly, the script monitors the lowest prices within that same five-bar window. If it finds a point where a specific trough is lower than the two candles before it and the two candles after it, it recognizes this as a significant low point. In these instances, the tool places a different visual marker on the chart to highlight a potential support level or price floor.
Visual Representation
The script translates these mathematical comparisons into clear visual cues:
- Gold Markers: These appear at identified high points (Upside Fractals).
- Lime Markers: These appear at identified low points (Downside Fractals).
By automatically filtering the "noise" of the market and only marking these specific structural turns, the script allows you to see the primary framework of price action more clearly. It essentially acts as an automated scout, scanning the historical and current candles to pin down where the market has successfully shifted direction.
//+------------------------------------------------------------------+
//| FractalBest.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Gold
#property indicator_color2 Lime
//---- input parameters
extern int ExtParam1;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,241);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,242);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexEmptyValue(1,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start(){
int shift;
double up,dw,nul=0.0001;
int i;
for(shift=Bars-3;shift>=0;shift--){
ExtMapBuffer1[shift]=0;
ExtMapBuffer2[shift]=0;
}
//----Up and Down Fractals
//----5 bars Fractal
if(High[3]>High[4] && High[3]>High[5] && High[3]>High[2] && High[3]>High[1]){
up=Low[0]-3*Point;
ExtMapBuffer1[0]=up;
}
else{
ExtMapBuffer1[0]=nul;
}
if(Low[3]<Low[4] && Low[3]<Low[5] && Low[3]<Low[2] && Low[3]<Low[1]){
dw=High[0]+3*Point;
ExtMapBuffer2[0]=dw;
}
else{
ExtMapBuffer2[0]=nul;
}
return(0);
}
//+------------------------------------------------------------------+
Comments