FractalsPaint
Download scriptThis tool is designed to enhance your trading charts by automatically identifying and highlighting specific price action patterns known as "fractals." These patterns are essential for many traders who use them to identify potential zones of support and resistance in the market.
Core Functionality
The script scans historical price data to find specific price peaks and troughs. Instead of simply looking at a single candle, it analyzes a local cluster of candles to determine if a price point is significant enough to be considered a "fractal."
- Resistance Identification (High Fractals): The logic looks for a high point that is higher than the surrounding candles on its left and right. When this condition is met, the script identifies a potential ceiling where the price might struggle to move higher.
- Support Identification (Low Fractals): Conversely, the logic searches for low points that are lower than their neighboring candles. These are identified as potential floors where the price might find a base to bounce from.
How It Works on Your Chart
The script processes these calculations and visually represents them using two distinct color-coded indicators:
- Visual Mapping: It distinguishes between upward and downward trends. When a significant low is detected (a support fractal), the tool marks it accordingly. When a significant high is detected (a resistance fractal), it highlights that point separately.
- Data Handling: The script includes a "Shift" feature, allowing you to adjust how far back from the current price the analysis begins. It also manages the data flow efficiently, ensuring that as new candles form, the tool continues to map out these historical points accurately.
- Visual Clarity: By using different colors (Red and Blue), the script provides a clear visual distinction between resistance and support, allowing you to see the "geography" of the market at a glance without having to manually calculate which peaks are significant.
Summary for Traders
Essentially, this script acts as an automated scout. It combs through the price history to find the "turning points"—the moments where the market direction paused or reversed—and marks them clearly on your screen. This helps you visualize where previous price action has stalled, providing a clearer picture of the market's structural boundaries.
//+------------------------------------------------------------------+
//| FractalsPaint.mq4 |
//| Copyright © 2006 Scorpion@fxfisherman.com |
//+------------------------------------------------------------------+
#property copyright "FxFisherman.com"
#property link "http://www.fxfisherman.com"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
extern int Shift_Bars=0;
int Bars_Count= 0;
//---- buffers
double v1[];
double v2[];
int init()
{
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,v1);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,v2);
watermark();
return(0);
}
int start()
{
bool hiFractal;
bool loFractal;
int curFractal;
double price;
int i;
int shift;
int counted_bars = IndicatorCounted();
if (counted_bars > 0) counted_bars--;
if (Bars_Count > 0 && Bars_Count <= Bars)
{
i = Bars_Count - counted_bars;
}else{
i = Bars - counted_bars;
}
while(i>=0)
{
shift = i + Shift_Bars;
// Resistance
price = High[shift+3];
hiFractal = price > High[shift+5] &&
price >= High[shift+4] &&
price > High[shift+2] &&
price > High[shift+1];
// Support
price = Low[shift+3];
loFractal = price < Low[shift+5] &&
price <= Low[shift+4] &&
price < Low[shift+2] &&
price < Low[shift+1];
if (hiFractal && !loFractal) {
curFractal = -1;
}else if(loFractal && !hiFractal) {
curFractal = 1;
}else if(loFractal && hiFractal){
curFractal = 0;
}
if (curFractal == 1) {
v2[i] = High[i];
v1[i] = Low[i];
}else if(curFractal == -1) {
v1[i] = High[i];
v2[i] = Low[i];
}else{
v1[i] = Low[i];
v2[i] = Low[i];
}
i--;
}
return(0);
}
//+------------------------------------------------------------------+
void watermark()
{
ObjectCreate("fxfisherman", OBJ_LABEL, 0, 0, 0);
ObjectSetText("fxfisherman", "fxfisherman.com", 11, "Lucida Handwriting", RoyalBlue);
ObjectSet("fxfisherman", OBJPROP_CORNER, 2);
ObjectSet("fxfisherman", OBJPROP_XDISTANCE, 5);
ObjectSet("fxfisherman", OBJPROP_YDISTANCE, 10);
return(0);
}
Comments