3color_RSX_H





//+==================================================================+
//|                                                 3color_RSX_H.mq4 |
//|                Copyright © 2005, Nick Bilak, beluck[AT]gmail.com |
//|                                    http://metatrader.50webs.com/ |
//|                     MQL4 © 2005,                Nikolay Kositsin |  
//+==================================================================+

#property copyright "Copyright © 2005, Nick Bilak"
#property link      "http://metatrader.50webs.com/"
#property indicator_separate_window
#property indicator_buffers  3
#property indicator_color1  Lime
#property indicator_color2  Red
#property indicator_color3  Gray
#property indicator_level1  0.4
#property indicator_level2 -0.4
#property indicator_level3  0.0
#property indicator_maximum  1
#property indicator_minimum -1
//---- input parameters
extern int       Lengh = 14;
extern int   CountBars = 300;
//---- buffers
double Ind_buffer1[];
double Ind_buffer2[];
double Ind_buffer3[];
double RSX_Bufer[];
double MEM[30][12];
//----
int    r=0, w=0, k=0, x;
//----
double v20=0.0, Kg=0.0,  Hg=0.0,  f28=0.0, Vol, minuse;
double f0=0.0,  v4=0.0,  v8=0.0,  v0C=0.0, v10=0.0, v14=0.0, v18=0.0;
double f30=0.0, f38=0.0, f48=0.0, v1C=0.0, F28=0.0, f40=0.0, v8A=0.0;
double f50=0.0, f58=0.0, f60=0.0, f68=0.0, f70=0.0, f78=0.0, f80=0.0;
//+==================================================================+
//| Custom indicator initialization function                         |
//+==================================================================+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM, STYLE_SOLID);
   SetIndexStyle(1,DRAW_HISTOGRAM, STYLE_SOLID);
   SetIndexStyle(2,DRAW_HISTOGRAM, STYLE_SOLID);
//----   
   IndicatorBuffers(5);
   SetIndexBuffer(0,Ind_buffer1);
   SetIndexBuffer(1,Ind_buffer2);
   SetIndexBuffer(2,Ind_buffer3);
   SetIndexBuffer(3,RSX_Bufer);
   SetIndexBuffer(4,MEM);
//----  
   IndicatorShortName("RSXC("+Lengh+")");
   ArrayInitialize(RSX_Bufer,50.0);
   ArrayInitialize(MEM,0.0);
//----   
   SetIndexDrawBegin(0,Bars-CountBars);
   SetIndexDrawBegin(1,Bars-CountBars);
   SetIndexDrawBegin(2,Bars-CountBars);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//----  
   if (Lengh-1>=5) w=Lengh-1; else w=5; Kg=3/(Lengh+2.0); Hg=1.0-Kg;
//----
return(0);
  }
//+==================================================================+
//| Custom indicator initialization function                         |
//+==================================================================+
int start()
{
int counted_bars=IndicatorCounted(),shift=0;
if (counted_bars<0) return(-1);

if(counted_bars<=Lengh)shift=Bars-Lengh-1; 
                  else shift=Bars-counted_bars-1;

if(Bars-counted_bars>30-2)shift=Bars-1;//double MEM[30][12];
if(shift==0) x=1; else x=shift;

f28=MEM[x][ 0];f30=MEM[x][ 1];f38=MEM[x][ 2];f40=MEM[x][ 3];
f48=MEM[x][ 4];f50=MEM[x][ 5];f58=MEM[x][ 6];f60=MEM[x][ 7];
f68=MEM[x][ 8];f70=MEM[x][ 9];f78=MEM[x][10];f80=MEM[x][11];

while (shift >= 0)

{//================================
if(r==0)
{//...
r = 1; k = 0;
}//...
else
{//++++++++++++++++++++
if (r>=w) r=w+1; else r=r+1;

v8 = 100*(Close[shift]-Close[shift+1]); v8A=MathAbs(v8);

//---- âû÷èñëåíèå V14 ------
f28 = Hg  * f28 + Kg  *  v8;
f30 = Kg  * f28 + Hg  * f30;
v0C = 1.5 * f28 - 0.5 * f30;
f38 = Hg  * f38 + Kg  * v0C;
f40 = Kg  * f38 + Hg  * f40;
v10 = 1.5 * f38 - 0.5 * f40;
f48 = Hg  * f48 + Kg  * v10;
f50 = Kg  * f48 + Hg  * f50;
v14 = 1.5 * f48 - 0.5 * f50;
//---- âû÷èñëåíèå V20 ------
f58 = Hg  * f58 + Kg  * v8A;
f60 = Kg  * f58 + Hg  * f60;
v18 = 1.5 * f58 - 0.5 * f60;
f68 = Hg  * f68 + Kg  * v18;
f70 = Kg  * f68 + Hg  * f70;
v1C = 1.5 * f68 - 0.5 * f70;
f78 = Hg  * f78 + Kg  * v1C;
f80 = Kg  * f78 + Hg  * f80;
v20 = 1.5 * f78 - 0.5 * f80;
//-------wwwwwwwwww---------
if ((r <= w) && (v8!= 0)) k = 1;
if ((r == w) && (k == 0)) r = 0;
}//++++++++++++++++++++
if ((r >  w) &&(v20 > 0.0000000001 ))///0.0000000001=={1.0e-10};
{//...
v4 = (v14/v20+1.0)*50.0; if(v4>100.0)v4=100.0; if(v4<0.0)v4=0.0;
}//...
else  v4 = 50.0;

RSX_Bufer[shift]=v4/50-1;

//------------  
if(shift<2)
{
MEM[shift][ 0]=f28;MEM[shift][ 1]=f30;MEM[shift][ 2]=f38;MEM[shift][ 3]=f40;
MEM[shift][ 4]=f48;MEM[shift][ 5]=f50;MEM[shift][ 6]=f58;MEM[shift][ 7]=f60;
MEM[shift][ 8]=f68;MEM[shift][ 9]=f70;MEM[shift][10]=f78;MEM[shift][11]=f80;
}
//---- Three Colour code+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Vol = RSX_Bufer[shift];     minuse = Vol - RSX_Bufer[shift+1];  
     
      if(minuse>0.0){Ind_buffer1[shift]=Vol; Ind_buffer2[shift]=0.0; Ind_buffer3[shift]=0.0;} 
else {if(minuse<0.0){Ind_buffer1[shift]=0.0; Ind_buffer2[shift]=Vol; Ind_buffer3[shift]=0.0;}
else                {Ind_buffer1[shift]=0.0; Ind_buffer2[shift]=0.0; Ind_buffer3[shift]=Vol;}}     
 //---- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

shift--;

}//================================
return(0);
}










Sample





Analysis



Market Information Used:

Series array that contains close prices for each bar


Indicator Curves created:

Implements a curve of type DRAW_HISTOGRAM


Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features: