Priliv
Download scriptThis script functions as a multi-layered trend analysis tool designed to visualize the "velocity" or momentum of price movements across different time horizons simultaneously. Instead of just showing where the price is, it focuses on how fast and in what direction the price is moving relative to several significant milestones.
Core Logic Overview
The indicator generates three distinct lines that represent trend speeds. It achieves this by calculating the difference between a moving average at the current moment and its value at specific historical offsets. By summing these differences over a series of points, it creates a smoothed representation of momentum.
The Three Trend Layers
The script breaks down the market's behavior into three distinct "views":
- Current Timeframe Velocity: This line represents the immediate trend speed on your current chart. It helps identify the strength of the present movement.
- Next Largest Timeframe: This line calculates the momentum for a larger timeframe (the next logical step up from your current view). It allows you to see if the broader market is moving in harmony with your current trade or if it is pulling in a different direction.
- Trend After Next: The final line looks even further out, projecting the trend of an even larger timeframe. This is intended to provide a "macro" perspective on the market's primary trajectory.
Dynamic Adaptation
A key feature of this logic is its ability to automatically adjust based on the chart's timeframe. The script contains a built-in mapping system that detects your current time interval (e.g., 1-minute, 1-hour, Daily) and automatically adjusts the mathematical multipliers for the different trend layers. This ensures that the "distance" it looks back to calculate momentum remains proportional and relevant whether you are day trading or swing trading.
Visual Interpretation
- Trend Strength: The vertical movement of these lines indicates how aggressively the price is moving. A steeper slope suggests a stronger, faster trend.
- Trend Reversals: One of the primary ways to use this logic is by watching for "crossovers" or significant turns in the lines. When the lines begin to curve back on themselves or cross one another, it signals a potential shift in the direction of the market trend.
- Confluence: By viewing all three lines together, a user can identify "confluence"—situations where all three timeframes are moving in the same direction simultaneously, which often indicates a high-probability, sustained trend.
//ææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææ
// Priliv.mq4
// Ðàçâîðîòíûé èíäèêàòîð.
// Ðàñïðîñòðàíÿåòñÿ áåñïëàòíî áåç îãðàíè÷åíèé.
// Ñåðãåé Êîâàë¸â, Äíåïðîïåòðîâñê, sk@mail.dnepr.net, http://autograf.dp.ua , ICQ 64015987
//--------------------------------------------------------------------------------------------------------------------
// Îòîáðàæàåò 3 ëèíèè ðàçíîãî öâåòà, ïîêàçûâàÿ ñêîðîñòü òðåíäà íà òåêóùåì, áëèæàéøåì áîëüøåì è ñëåäóþùåì áîëüøåì ÒÔ.
// Áåæåâûé öâåò ëèíèè îçíà÷àåò ðàñ÷¸ò ñ íàèìåíüøèì ïåðèîäîì (òåêóùèé ÒÔ). Çåë¸íûé öâåò - îòîáðàæåíèå â òåêóùåì ÒÔ
// ëèíèè áëèæàéøåãî ñòàðøåãî ÒÔ. Êðàñíàÿ ëèíèÿ èñïîëüçóåòñÿ äëÿ îòîáðàæåíèÿ òåíäåíöèè â ñëåäóþùåì ñòàðøåì ÒÔ.
// Ìîæåò ïðèìåíÿòüñÿ íà ëþáûõ òàéìôðåéìàõ. Ïåðåãèá èíäèêàòîðà îçíà÷àåò ñìåíó íàïðàâëåíèÿ òðåíäà.
//--------------------------------------------------------------------------------------------------------------------
#property copyright "Copyright © SK, 2006"
#property link "http://autograf.dp.ua"
//ææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææ
//
//
//ææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææ
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 CornflowerBlue
#property indicator_color2 DarkGoldenrod
#property indicator_color3 Red
#property indicator_color4 Magenta
#property indicator_style1 0
#property indicator_style2 0
#property indicator_style3 2
#property indicator_style4 4
//--------------------------------------------------------------------------------------------------------------------
extern int CountBars=2000;
double Buf_1[]; // Áóôôåð îïîðíîé MA
double Buf_2[]; // Áóôôåð èíäèêàòîðà òåêóùåãî ÒÔ
double Buf_3[]; // Áóôôåð èíäèêàòîðà áëèæàéøåãî áîëüøåãî ÒÔ
double Buf_4[]; // Áóôôåð èíäèêàòîðà ñëåäóþùåãî áîëüøåãî ÒÔ
double MA_0, MA_11, MA_12, MA_13, MA_14;
double Polzun_1[21],Polzun_2[21],Polzun_3[21],Line[21];
double KK=1.2;
double K=5;
//--------------------------------------------------------------------------------------------------------------------
int i,n,k, counted_bars, K2, K3, Period_MA_2, Period_MA_3;
int Period_MA_0 = 8;
int Period_MA_1 = 21;
int Kol_Line=20;
//ææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææ
int init()
{
switch(Period())
{
case 1: K2=5; K3=15; break;
case 5: K2=3; K3= 6; break;
case 15: K2=2; K3= 4; break;
case 30: K2=2; K3= 8; break;
case 60: K2=4; K3=24; break;
case 240: K2=6; K3=42; break;
case 1440: K2=7; K3=30; break;
case 10080: K2=4; K3= 0; break;
case 43200: K2=0; K3= 0; break;
}
Polzun_1[1]=20;
Polzun_2[1]=Polzun_1[1]*K2; Period_MA_2=Period_MA_1*K2;
Polzun_3[1]=Polzun_1[1]*K3; Period_MA_3=Period_MA_1*K3;
//--------------------------------------------------------------------------------------------------------------------
SetIndexStyle (0,DRAW_LINE);
SetIndexBuffer(0,Buf_1);
SetIndexDrawBegin(0, MathMin(Bars-CountBars,Bars-Period_MA_1*K2));
//--------------------------------------------------------------------------------------------------------------------
SetIndexStyle (1,DRAW_LINE);
SetIndexBuffer(1,Buf_2);
SetIndexDrawBegin(1, MathMin(Bars-CountBars,Bars-Period_MA_1*K2));
//--------------------------------------------------------------------------------------------------------------------
SetIndexStyle (2,DRAW_LINE);
SetIndexBuffer(2,Buf_3);
SetIndexDrawBegin(2, MathMin(Bars-CountBars,Bars-Period_MA_1*K3));
//--------------------------------------------------------------------------------------------------------------------
SetIndexStyle (3,DRAW_LINE);
SetIndexBuffer(3,Buf_4);
SetIndexDrawBegin(3, MathMin(Bars-CountBars,Bars-Period_MA_1*K3));
//--------------------------------------------------------------------------------------------------------------------
SetIndexLabel(0,"baseMA");
SetIndexLabel(1,"VelCurrTF");
SetIndexLabel(2,"VelNextTF");
SetIndexLabel(3,"VelTFafterNext");
return(0);
}
//ææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææ
int start()
{
counted_bars=IndicatorCounted();
i=Bars-counted_bars-1;
//--------------------------------------------------------------------------------------------------------------------
for (n=2;n<=Kol_Line;n++)
{
k=n-1;
Polzun_1[n]=Polzun_1[k]/KK;
Polzun_2[n]=Polzun_2[k]/KK;
Polzun_3[n]=Polzun_3[k]/KK;
}
//====================================================================================================================
while(i>=0)
{
//--------------------------------------------------------------------------------------------------------------------
MA_0 = iMA( NULL, 0, Period_MA_0, 0, MODE_LWMA, PRICE_TYPICAL, i );
Buf_1[i]=MA_0; // Îïîðíàÿ ÌÀ
//--------------------------------------------------------------------------------------------------------------------
Buf_2[i]= 0;
MA_11 = iMA( NULL, 0, Period_MA_1, 0, MODE_LWMA, PRICE_TYPICAL, i );
for (n=1;n<=Kol_Line;n++)
{
MA_12 = iMA( NULL, 0, Period_MA_1, 0, MODE_LWMA, PRICE_TYPICAL, i +Polzun_1[n]);
Line[n] = MA_11-MA_12;
Buf_2[i] = Buf_2[i]+Line[n];
}
Buf_2[i]= MA_0 + K*Buf_2[i]/Kol_Line;
//--------------------------------------------------------------------------------------------------------------------
Buf_3[i]= 0;
MA_11 = iMA( NULL, 0, Period_MA_2, 0, MODE_LWMA, PRICE_TYPICAL, i );
for (n=1;n<=Kol_Line;n++)
{
MA_12 = iMA( NULL, 0, Period_MA_2, 0, MODE_LWMA, PRICE_TYPICAL, i +Polzun_2[n]);
Line[n] = MA_11-MA_12;
Buf_3[i] = Buf_3[i]+Line[n];
}
Buf_3[i]= iMA( NULL, 0, Period_MA_0*K2, 0, MODE_LWMA, PRICE_TYPICAL, i) + K*Buf_3[i]/Kol_Line;
if (K2==0)Buf_3[i]=0;
//--------------------------------------------------------------------------------------------------------------------
Buf_4[i]= 0;
MA_11 = iMA( NULL, 0, Period_MA_3, 0, MODE_LWMA, PRICE_TYPICAL, i );
for (n=1;n<=Kol_Line;n++)
{
MA_12 = iMA( NULL, 0, Period_MA_3, 0, MODE_LWMA, PRICE_TYPICAL, i +Polzun_3[n]);
Line[n] = MA_11-MA_12;
Buf_4[i] = Buf_4[i]+Line[n];
}
Buf_4[i]= iMA( NULL, 0, Period_MA_0*K3, 0, MODE_LWMA, PRICE_TYPICAL, i) + K*Buf_4[i]/Kol_Line;
if (K3==0)Buf_4[i]=0;
//--------------------------------------------------------------------------------------------------------------------
i--;
}
//for (int i=0;i<=indicator_buffers;i++) SetIndexDrawBegin(i, MathMin(Bars-CountBars,Bars-Period_MA_1*K3));
//====================================================================================================================
return(0);
}
//ææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææ
int deinit()
{
return(0);
}
//ææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææ
Comments