#property copyright "Copyright ?SK, 2006"
#property link "http://autograf.dp.ua"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 White
#property indicator_color2 Wheat
#property indicator_color3 DarkSeaGreen
#property indicator_color4 DarkSalmon
//--------------------------------------------------------------------------------------------------------------------
double Buf_1[];
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);
//--------------------------------------------------------------------------------------------------------------------
SetIndexStyle (1,DRAW_LINE);
SetIndexBuffer(1,Buf_2);
//--------------------------------------------------------------------------------------------------------------------
SetIndexStyle (2,DRAW_LINE);
SetIndexBuffer(2,Buf_3);
//--------------------------------------------------------------------------------------------------------------------
SetIndexStyle (3,DRAW_LINE);
SetIndexBuffer(3,Buf_4);
//--------------------------------------------------------------------------------------------------------------------
return(0);
}
int start()
{
int counted_bars=IndicatorCounted();
if(counted_bars0) counted_bars--;
int limit=Bars-counted_bars;
if(counted_bars==0) limit--;
i=limit;
//--------------------------------------------------------------------------------------------------------------------
for (n=2;n=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--;
}
//====================================================================================================================
return(0);
}
int deinit()
{
return(0);
}
|