olyakish_fractals_01
Download scriptThis script is designed as a visual analysis tool for the MetaTrader platform. It identifies specific patterns in price action by comparing "fractals"—which are essentially structural peaks and valleys in a chart—against trading volume and momentum data.
Instead of simply showing every price peak, this tool categorizes these points into four distinct types based on their relative strength. To do this, it looks at the current fractal point and compares it to the next available fractal in the historical sequence. It evaluates two main factors:
- Volume: The total amount of trading activity occurring around the fractal point.
- Momentum (MFI): A calculation of the price range (highs vs. lows) relative to the volume during that specific period.
By comparing these two factors between two consecutive points, the logic classifies each peak or valley into one of four visual categories:
- Strong Fractal (Lime): Occurs when both the trading volume and the momentum are increasing compared to the previous point. This suggests a powerful trend with high participation.
- Weak Fractal (Saddle Brown): Occurs when both the trading volume and the momentum are decreasing. This may indicate a loss of interest or a fading trend.
- Increasing Fractal (Red): Identified when volume is rising but momentum is falling.
- Decreasing Fractal (Blue): Identified when volume is falling but momentum is rising.
The script automatically scans the chart history to find these points and plots colored arrows at the correct price levels. This allows a trader to quickly see whether a price reversal or continuation is backed by significant "effort" (volume) and "result" (momentum), helping to distinguish between high-quality structural shifts and insignificant market noise.
//+------------------------------------------------------------------+
//| olyakish_fractals_01 |
//| Copyright © -2007, olyakish |
//| plutonia-dmb#yandex.ru |
//+------------------------------------------------------------------+
#property copyright "olyakish"
#property link "plutonia-dmb#yandex.ru"
//----
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Green // Çåëåíûé ôðàêòàë
#property indicator_color2 Red // Ïðèñåäàþùèé
#property indicator_color3 Brown // Óâÿäàþùèé
#property indicator_color4 Blue // Ôàëüøèâûé
//----
extern int Pips = 15;
extern int ShiftBars = 150;
double ExtLimeBuffer[];
double ExtRedBuffer[];
double ExtSaddleBrownBuffer[];
double ExtBlueBuffer[];
int i,j;
double a_Fractal[2]; // 0- ïîñëåäíèé 1-ïðåäûäóùèé
double a_MFI[2]; // 0- ïîñëåäíèé 1-ïðåäûäóùèé
double a_Volume[2]; // 0- ïîñëåäíèé 1-ïðåäûäóùèé
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0, ExtLimeBuffer);
SetIndexBuffer(1, ExtRedBuffer);
SetIndexBuffer(2, ExtSaddleBrownBuffer);
SetIndexBuffer(3, ExtBlueBuffer);
//----
SetIndexStyle(0, DRAW_ARROW, 0, 1);
SetIndexStyle(1, DRAW_ARROW, 0, 1);
SetIndexStyle(2, DRAW_ARROW, 0, 1);
SetIndexStyle(3, DRAW_ARROW, 0, 1);
SetIndexArrow(0, 177);
SetIndexArrow(1, 177);
SetIndexArrow(2, 177);
SetIndexArrow(3, 177);
///----
SetIndexLabel(0, "Çåëåíûé ôðàêòàë");
SetIndexLabel(1, "Ïðèñåäàþùèé ôðàêòàë");
SetIndexLabel(2, "Óâÿäàþùèé ôðàêòàë");
SetIndexLabel(3, "Ôàëüøèâûé ôðàêòàë");
//----
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int deinit()
{
Comment("");
Comment("");
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int n = 3;
while(ExtLimeBuffer[n] != NULL || ExtRedBuffer[n] != NULL ||
ExtSaddleBrownBuffer[n] != NULL || ExtBlueBuffer[n] != NULL)
{
if(n > ShiftBars)
{
n = ShiftBars;
break;
}
n++;
}
for(int i = n + 20; i >= 3; i--)
{
//-- âåðõíèå ôðàêòàëû
ArrayInitialize(a_Fractal, 0);
ArrayInitialize(a_MFI, 0);
ArrayInitialize(a_Volume, 0);
// íà i áàðå åñòü ôðàêòàë ââåðõ
if(iFractals(NULL, 0, MODE_UPPER, i) != 0)
{
Comment("olyakish_fractals_01\n",i, ", ", j);
Sleep(1000);
// öåíà íà ôðàêòàëå
a_Fractal[0] = iFractals(NULL, 0, MODE_UPPER, i);
a_Volume[0] = Volume[i] + Volume[i+1] + Volume[i+2] +
Volume[i-1] + Volume[i-2]; // îáúåì
a_MFI[0] = (High[i] - Low[i] + High[i-1] - Low[i-1] +
High[i-2] - Low[i-2] + High[i+1] - Low[i+1] +
High[i+2] - Low[i+2]) / a_Volume[0]; // MFI
// ïîøëè èñêàòü ôðàêòàë íà âíèç ïî èñòîðèè
j = i + 1;
while(a_Fractal[1] == 0)
{
if(iFractals(NULL, 0, MODE_UPPER, j) != 0)
{
break;
}
//-- Íàøëè ôðàêòàë âíèç
if(iFractals(NULL, 0, MODE_LOWER, j) != 0)
{
a_Fractal[1] = iFractals(NULL, 0, MODE_LOWER, j);
a_Volume[1] = Volume[j+2] + Volume[j+1] + Volume[j] +
Volume[j-1] + Volume[j-2];
a_MFI[1] = (High[j+1] - Low[j+1] + High[j+2] -
Low[j+2] + High[j] - Low[j] + High[j-1] -
Low[j-1] + High[j-2] - Low[j-2]) / a_Volume[1];
if(a_Volume[0] > a_Volume[1] && a_MFI[0] < a_MFI[1])
{
// èìååì ïðèñåäàþùèé ôðàêòàë (MFI - îáúåì +)
ExtRedBuffer[i] = High[i]; // + Pips*Point;
break;
}
if(a_Volume[0] > a_Volume[1] && a_MFI[0] > a_MFI[1])
{
// èìååì çåëåíûé ôðàêòàë (MFI + îáúåì +)
ExtLimeBuffer[i] = High[i]; // + Pips*Point;
break;
}
if(a_Volume[0] < a_Volume[1] && a_MFI[0] > a_MFI[1])
{
// èìååì ôàëüøèâûé ôðàêòàë (MFI + îáúåì -)
ExtBlueBuffer[i] = High[i]; // + Pips*Point;
break;
}
if(a_Volume[0] < a_Volume[1] && a_MFI[0] < a_MFI[1])
{
// èìååì óâÿäàþùèé ôðàêòàë (MFI - îáúåì -)
ExtSaddleBrownBuffer[i] = High[i]; // + Pips*Point;
break;
}
}
j++;
}
}
//--- íèæíèå ôðàêòàëû
ArrayInitialize(a_Fractal, 0);
ArrayInitialize(a_MFI, 0);
ArrayInitialize(a_Volume, 0);
// íà i áàðå åñòü ôðàêòàë âíèç
if(iFractals(NULL, 0, MODE_LOWER, i) != 0)
{
// öåíà íà ôðàêòàëå
a_Fractal[0] = iFractals(NULL, 0, MODE_LOWER, i);
a_Volume[0] = Volume[i] + Volume[i+1] + Volume[i+2] +
Volume[i-1] + Volume[i-2]; // îáúåì
a_MFI[0] = (High[i] - Low[i] + High[i-1] - Low[i-1] +
High[i-2] - Low[i-2] + High[i+1] - Low[i+1] +
High[i+2] - Low[i+2]) / a_Volume[0]; // MFI
// ïîøëè èñêàòü ôðàêòàë íà ââåðõ ïî èñòîðèè
j = i + 1;
while(a_Fractal[1] == 0)
{
if(iFractals(NULL, 0, MODE_LOWER, j) != 0)
{
break;
}
//-- Íàøëè ôðàêòàë ââåðõ
if(iFractals(NULL, 0, MODE_UPPER, j) != 0)
{
a_Fractal[1] = iFractals(NULL, 0, MODE_UPPER, j);
a_Volume[1] = Volume[j+2] + Volume[j+1] + Volume[j] +
Volume[j-1] + Volume[j-2];
a_MFI[1] = (High[j+1] - Low[j+1] + High[j+2] - Low[j+2] +
High[j] - Low[j] + High[j-1] - Low[j-1] +
High[j-2] - Low[j-2]) / a_Volume[1];
if(a_Volume[0] > a_Volume[1] && a_MFI[0] < a_MFI[1])
{
// èìååì ïðèñåäàþùèé ôðàêòàë (MFI - îáúåì +)
ExtRedBuffer[i] = Low[i]; // - Pips*Point;
break;
}
if(a_Volume[0] > a_Volume[1] && a_MFI[0] > a_MFI[1])
{
// èìååì çåëåíûé ôðàêòàë (MFI + îáúåì +)
ExtLimeBuffer[i] = Low[i]; // - Pips*Point;
break;
}
if(a_Volume[0] < a_Volume[1] && a_MFI[0] > a_MFI[1])
{
// èìååì ôàëüøèâûé ôðàêòàë (MFI + îáúåì -)
ExtBlueBuffer[i] = Low[i]; // - Pips*Point;
break;
}
if(a_Volume[0] < a_Volume[1] && a_MFI[0] < a_MFI[1])
{
// èìååì óâÿäàþùèé ôðàêòàë (MFI - îáúåì -)
ExtSaddleBrownBuffer[i] = Low[i]; // - Pips*Point;
break;
}
}
j++;
}
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments