i-SKB-F
Download scriptOverview of the i-SKB-F Indicator Logic
The i-SKB-F script is a specialized technical analysis tool designed to identify and visualize market trends by analyzing price "fractals." In trading, fractals represent significant turning points—local highs and lows where the price reaches a peak or trough relative to its immediate surroundings. This indicator uses these historical turning points to project geometric trend lines onto your current chart.
Core Operational Logic
The script follows a systematic three-step process to determine how it draws the trend lines:
1. Identifying Key Turning Points The tool scans back through historical data on a specific timeframe (which you can customize) to find the most recent significant price peaks and valleys. It specifically looks for these "fractals" until it identifies three distinct points of interest. These points serve as the mathematical anchors for all subsequent calculations.
2. Geometric Trend Projection Once the script has identified these anchor points, it applies a geometric calculation (specifically a linear equation) to determine the trajectory of the market. Instead of just drawing a simple line between two points, the logic calculates how these points relate to one another to project "upper" and "lower" boundaries.
- It determines which points represent the highest and lowest structural levels.
- It then calculates the slope of the trend based on the relationship between these points.
3. Visualizing the Boundaries The final step is the rendering of these results onto your trading screen:
- Trend Lines: The script draws two distinct lines representing the upper and lower boundaries of the market movement. These are colored differently (SkyBlue and Salmon) to help you easily distinguish between support and resistance areas.
- Offset Adjustment: There is a built-in "buffer" or offset. This allows the lines to sit slightly away from the actual price points, which can help in identifying clearer "zones" of interest rather than just single price levels.
- Projection Rays: If enabled, the script extends these trend lines into the future as "rays." This provides a visual guide for where the market might travel based on the current geometric trajectory established by past fractals.
Summary for the User
Essentially, this tool takes the "noise" of price movement and simplifies it into a structured geometric map. By identifying three key historical peaks/valleys, it calculates the mathematical path of the current trend and projects it forward, allowing you to see potential corridors of price action more clearly.
//+------------------------------------------------------------------+
//| i-SKB-F.mq4 |
//| Êèì Èãîðü Â. aka KimIV |
//| http://www.kimiv.ru |
//| |
//| 13.06.2006 Ñêîëüçÿùèå êàíàëû Áàðèøïîëüöà íà Ôðàêòàëàõ. |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link "http://www.kimiv.ru"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 SkyBlue
#property indicator_color2 Salmon
//------- Ïîêëþ÷åíèå âíåøíèõ ìîäóëåé ---------------------------------
//------- Âíåøíèå ïàðàìåòðû èíäèêàòîðà -------------------------------
extern int FixedTF=60;
extern int OffSet =-3;
extern bool ShowRay=True;
//------- Ãëîáàëüíûå ïåðåìåííûå èíäèêàòîðà ---------------------------
double dBuf0[];
double dBuf1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void init()
{
if (ShowRay)
{
ObjectCreate("HL", OBJ_TREND, 0, 0,0,0,0);
ObjectCreate("LL", OBJ_TREND, 0, 0,0,0,0);
}
SetIndexBuffer(0, dBuf0);
SetIndexLabel (0, "HL");
SetIndexStyle (0, DRAW_LINE, STYLE_SOLID, 2);
SetIndexBuffer(1, dBuf1);
SetIndexLabel (1, "LL");
SetIndexStyle (1, DRAW_LINE, STYLE_SOLID, 2);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
void deinit()
{
ObjectDelete("HL");
ObjectDelete("LL");
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
void start()
{
double y3=0, y2=0, y1=0, zz; // ôðàêòàëû
double y4, u2, u1, d2, d1; // öåíîâûå óðîâíè ëèíèé
int x3, x2, x1, sh=2; // íîìåðà áàðîâ
string sL1, sL2;
color clU, clD;
// Áåð¸ì òðè ýêñòðåìóìà Çèã-Çàãà
while(y3==0)
{
zz=iFractals(NULL, FixedTF, MODE_UPPER, sh);
if (zz==0) zz=iFractals(NULL, FixedTF, MODE_LOWER, sh);
if (zz!=0)
{
if (y1==0) { x1=sh; y1=zz; }
else if (y2==0) { x2=sh; y2=zz; }
else if (y3==0) { x3=sh; y3=zz; }
}
sh++;
}
y4=EquationDirect(x3, y3, x1, y1, x2);
if (y2>y1)
{
u2=y3+y2-y4;
u1=EquationDirect(x3, u2, x2, y2, 0);
d2=y3;
d1=EquationDirect(x3, y3, x1, y1, 0);
}
else
{
u2=y3;
u1=EquationDirect(x3, y3, x1, y1, 0);
d2=y3+y2-y4;
d1=EquationDirect(x3, d2, x2, y2, 0);
}
u2+=OffSet*Point; u1+=OffSet*Point;
d2-=OffSet*Point; d1-=OffSet*Point;
x2=iBarShift(NULL, 0, iTime(NULL, FixedTF, x3));
for(sh=x2; sh>=0; sh--)
{
dBuf0[sh]=EquationDirect(x2, u2, 0, u1, sh);
dBuf1[sh]=EquationDirect(x2, d2, 0, d1, sh);
}
if (ShowRay)
{
ObjectSet("HL", OBJPROP_TIME1 , iTime(NULL, FixedTF, x3));
ObjectSet("HL", OBJPROP_TIME2 , Time[0]);
ObjectSet("HL", OBJPROP_PRICE1, u2);
ObjectSet("HL", OBJPROP_PRICE2, u1);
ObjectSet("HL", OBJPROP_BACK , True);
ObjectSet("HL", OBJPROP_RAY , True);
ObjectSet("HL", OBJPROP_STYLE , STYLE_DOT);
ObjectSet("HL", OBJPROP_WIDTH , 1);
ObjectSet("HL", OBJPROP_COLOR , indicator_color1);
//
ObjectSet("LL", OBJPROP_TIME1 , iTime(NULL, FixedTF, x3));
ObjectSet("LL", OBJPROP_TIME2 , Time[0]);
ObjectSet("LL", OBJPROP_PRICE1, d2);
ObjectSet("LL", OBJPROP_PRICE2, d1);
ObjectSet("LL", OBJPROP_BACK , True);
ObjectSet("LL", OBJPROP_RAY , True);
ObjectSet("LL", OBJPROP_STYLE , STYLE_DOT);
ObjectSet("LL", OBJPROP_WIDTH , 1);
ObjectSet("LL", OBJPROP_COLOR , indicator_color2);
}
}
//+------------------------------------------------------------------+
//| Óðàâíåíèå ïðÿìîé. |
//| Âû÷èñëÿåò çíà÷åíèå Y äëÿ X â òî÷êå ïåðåñå÷åíèÿ ñ ïðÿìîé. |
//| Ïàðàìåòðû: |
//| x1,y1 - êîîðäèíàòû ïåðâîé òî÷êè, |
//| x2,y2 - êîîðäèíàòû âòîðîé òî÷êè, |
//| x - çíà÷åíèå, äëÿ êîòîðîãî âû÷èñëèòü Y |
//+------------------------------------------------------------------+
double EquationDirect(double x1, double y1, double x2, double y2, double x)
{
if ((x2-x1)*(x-x1)==0) return(y1);
return((y2-y1)/(x2-x1)*(x-x1)+y1);
}
//+------------------------------------------------------------------+
Comments