envelopes_of_stochastic.mq4
envelopes_of_stochastic.mq4 FOREX MetaTrader4 Indicators Download
envelopes_of_stochastic.mq4 download link will appear after 20 seconds.
envelopes_of_stochastic.mq4 Programming source code.
//---- indicator settings #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Gray #property indicator_color2 Blue #property indicator_color3 Red //---- indicator parameters extern int StochPeriod = 14; extern int StochSlowing = 3; extern int Applied_Price=0; extern int MA_Period=14; extern int MA_Method=0; extern double Deviation=0.1; //---- indicator buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double stoch[]; //---- //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { int draw_begin; //---- drawing settings if(MA_Period<2) MA_Period=14; draw_begin=MA_Period-1; SetIndexBuffer(0,stoch); SetIndexBuffer(1,ExtMapBuffer1); SetIndexBuffer(2,ExtMapBuffer2); if(Deviation<0.1) Deviation=0.1; if(Deviation>100.0) Deviation=100.0; //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit; if(Bars<=MA_Period) return(0); int ExtCountedBars=IndicatorCounted(); //---- check for possible errors if (ExtCountedBars<0) return(-1); //---- last counted bar will be recounted if (ExtCountedBars>0) ExtCountedBars--; limit=Bars-ExtCountedBars; //---- EnvelopesM counted in the buffers for(int i=limit; i>=0; i--) stoch[i] = iStochastic(NULL,0,StochPeriod,1,StochSlowing,MODE_SMA,Applied_Price,MODE_MAIN,i); for( i=limit; i>=0; i--) { ExtMapBuffer1[i] = (1+Deviation/100)*iMAOnArray(stoch,0,MA_Period,0,MA_Method,i); ExtMapBuffer2[i] = (1-Deviation/100)*iMAOnArray(stoch,0,MA_Period,0,MA_Method,i); } //---- done return(0); } //+------------------------------------------------------------------+