//+------------------------------------------------------------------+ //| Sum_Stochastic.mq4 | //| valenok2003@mail.ru | //| ICQ 365919666 | //| Пишу на заказ, цены договорные | //| http://www.mebel-for-you.com | //+------------------------------------------------------------------+ #property copyright "Sergey Gulyaev. Maykop." #property link "http://www.mebel-for-you.com" #property indicator_separate_window //#property indicator_chart_window #property indicator_minimum -110 #property indicator_maximum 110 #property indicator_buffers 8 #property indicator_color1 Red #property indicator_color2 Orange #property indicator_color3 Yellow #property indicator_color4 LimeGreen #property indicator_color5 SkyBlue #property indicator_color6 Blue #property indicator_color7 Violet #property indicator_color8 White extern int Stoch_D=5; extern int Stoch_K=3; extern int Stoch_S=3; extern string Rem_0 = "-период усреднения суммы-"; extern int Period_Average = 15; extern string Rem_1 = "-визуализация кривых-"; extern bool Show_Sum_Average = true; extern bool Show_Sum = false; extern bool Show_M1 = false; extern bool Show_M5 = false; extern bool Show_M15 = false; extern bool Show_M30 = false; extern bool Show_H1 = false; extern bool Show_H4 = false; //---- buffers double Sum_Average[],St_M1[],St_M5[],St_M15[],St_M30[],St_H1[],St_H4[],Sum_St[]; double D_M1, D_M5, D_M15, D_M30, D_H1, D_H4; double K_M1, K_M5, K_M15, K_M30, K_H1, K_H4; double S_M1, S_M5, S_M15, S_M30, S_H1, S_H4; double Tmp_Sum; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { D_M1=Stoch_D;D_M5=D_M1*5;D_M15=D_M1*15;D_M30=D_M1*30;D_H1=D_M1*60;D_H4=D_M1*240; K_M1=Stoch_K;K_M5=K_M1*5;K_M15=K_M1*15;K_M30=K_M1*30;K_H1=K_M1*60;K_H4=K_M1*240; S_M1=Stoch_S;S_M5=S_M1*5;S_M15=S_M1*15;S_M30=S_M1*30;S_H1=S_M1*60;S_H4=S_M1*240; //---- indicators - предусмотрена возможность отключения линий if(Show_Sum_Average == true) SetIndexStyle(0,DRAW_LINE); else SetIndexStyle(0,DRAW_NONE); SetIndexBuffer(0,Sum_Average); SetIndexLabel (0,"Sum_Average"); if(Show_M1 == true) SetIndexStyle(1,DRAW_LINE); else SetIndexStyle(1,DRAW_NONE); SetIndexBuffer(1,St_M1); SetIndexLabel (1,"M1 ("+Ds_0(D_M1)+", "+Ds_0(K_M1)+", "+Ds_0(S_M1)+")\n"); if(Show_M5 == true) SetIndexStyle(2,DRAW_LINE); else SetIndexStyle(2,DRAW_NONE); SetIndexBuffer(2,St_M5); SetIndexLabel (2,"M5 ("+Ds_0(D_M5)+", "+Ds_0(K_M5)+", "+Ds_0(S_M5)+")\n"); if(Show_M15 == true) SetIndexStyle(3,DRAW_LINE); else SetIndexStyle(3,DRAW_NONE); SetIndexBuffer(3,St_M15); SetIndexLabel (3,"M15 ("+Ds_0(D_M15)+", "+Ds_0(K_M15)+", "+Ds_0(S_M15)+")\n"); if(Show_M30 == true) SetIndexStyle(4,DRAW_LINE); else SetIndexStyle(4,DRAW_NONE); SetIndexBuffer(4,St_M30); SetIndexLabel (4,"M30 ("+Ds_0(D_M30)+", "+Ds_0(K_M30)+", "+Ds_0(S_M30)+")\n"); if(Show_H1 == true) SetIndexStyle(5,DRAW_LINE); else SetIndexStyle(5,DRAW_NONE); SetIndexBuffer(5,St_H1); SetIndexLabel (5,"H1 ("+Ds_0(D_H1)+", "+Ds_0(K_H1)+", "+Ds_0(S_H1)+")\n"); if(Show_H4 == true) SetIndexStyle(6,DRAW_LINE); else SetIndexStyle(6,DRAW_NONE); SetIndexBuffer(6,St_H4); SetIndexLabel (6,"H4 ("+Ds_0(D_H4)+", "+Ds_0(K_H4)+", "+Ds_0(S_H4)+")\n"); if(Show_Sum == true) SetIndexStyle(7,DRAW_LINE); else SetIndexStyle(7,DRAW_NONE); SetIndexBuffer(7,Sum_St); SetIndexLabel (7,"Sum_St"); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars = IndicatorCounted(); if(counted_bars < 0) return(-1); if(counted_bars > 0) counted_bars--; int i = Bars - counted_bars; if(counted_bars==0) i-=1+Period_Average; while(i>=0) // Цикл по непосчитанным барам { Tmp_Sum = 0; Tmp_Sum = iStochastic(NULL,1,D_M1,K_M1,S_M1,MODE_SMA,0,MODE_MAIN, i); if(Tmp_Sum > 50) St_M1[i] = (Tmp_Sum-50)*2; if(Tmp_Sum < 50) St_M1[i] = -(50-Tmp_Sum)*2; if(Tmp_Sum == 50) St_M1[i] = 0; Tmp_Sum = 0; Tmp_Sum = iStochastic(NULL,1,D_M5,K_M5,S_M5,MODE_SMA,0,MODE_MAIN, i); if(Tmp_Sum > 50) St_M5[i] = (Tmp_Sum-50)*2; if(Tmp_Sum < 50) St_M5[i] = -(50-Tmp_Sum)*2; if(Tmp_Sum == 50) St_M5[i] = 0; Tmp_Sum = 0; Tmp_Sum = iStochastic(NULL,1,D_M15,K_M15,S_M15,MODE_SMA,0,MODE_MAIN, i); if(Tmp_Sum > 50) St_M15[i] = (Tmp_Sum-50)*2; if(Tmp_Sum < 50) St_M15[i] = -(50-Tmp_Sum)*2; if(Tmp_Sum == 50) St_M15[i] = 0; Tmp_Sum = 0; Tmp_Sum = iStochastic(NULL,1,D_M30,K_M30,S_M30,MODE_SMA,0,MODE_MAIN, i); if(Tmp_Sum > 50) St_M30[i] = (Tmp_Sum-50)*2; if(Tmp_Sum < 50) St_M30[i] = -(50-Tmp_Sum)*2; if(Tmp_Sum == 50) St_M30[i] = 0; Tmp_Sum = 0; Tmp_Sum = iStochastic(NULL,1,D_H1,K_H1,S_H1,MODE_SMA,0,MODE_MAIN, i); if(Tmp_Sum > 50) St_H1[i] = (Tmp_Sum-50)*2; if(Tmp_Sum < 50) St_H1[i] = -(50-Tmp_Sum)*2; if(Tmp_Sum == 50) St_H1[i] = 0; Tmp_Sum = 0; Tmp_Sum = iStochastic(NULL,1,D_H4,K_H4,S_H4,MODE_SMA,0,MODE_MAIN, i); if(Tmp_Sum > 50) St_H4[i] = (Tmp_Sum-50)*2; if(Tmp_Sum < 50) St_H4[i] = -(50-Tmp_Sum)*2; if(Tmp_Sum == 50) St_H4[i] = 0; Tmp_Sum = 0; Sum_St[i] = (St_M1[i] + St_M5[i] + St_M15[i] + St_M30[i] + St_H1[i] + St_H4[i])/3; for(int n=0; n < Period_Average; n++) { Tmp_Sum = Tmp_Sum + Sum_St[i+n]; } Tmp_Sum = Tmp_Sum/Period_Average; Sum_Average[i] = Tmp_Sum; i--; } //---- return(0); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ string Ds_0(double DOUBLE) {return(DoubleToStr(DOUBLE,0));} //+------------------------------------------------------------------+