Navigation´╝ÜHome > Content >

RSI_HISTOGRAM_v2.mq4

Time: 2011-10-27 | Download file:RSI_HISTOGRAM_v2.mq4

//+------------------------------------------------------------------+
//|                                                          RSI.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+

#property link      ""

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_color3 DarkGoldenrod

//---- input parameters
extern int n=14;

//---- uffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexBuffer(0,ExtMapBuffer1);
   
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexBuffer(1,ExtMapBuffer2);
   
   SetIndexStyle(2,DRAW_ARROW,STYLE_SOLID,4);
   SetIndexArrow(2,158); 
   SetIndexBuffer(2,ExtMapBuffer3);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
IndicatorShortName("RSI_HISTOGRAM");   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   int i,bar;
   bar = Bars-counted_bars;
   double sum1,sum3;
   for (i=0;i<=bar;i++){
      int nt,sum2=0;

      sum1=iRSI(NULL,0,n,0,i+nt);
      sum3=sum1-50;
 if (sum1>50) sum2=1;
 if (sum1<50) sum2=2;

 if (sum2==1)
 {
 ExtMapBuffer1[i]=sum3;
 ExtMapBuffer3[i]=40;
 }
 
 if (sum2==2)
 {
 ExtMapBuffer2[i]=sum3;
 ExtMapBuffer3[i]=-40;
 }
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Recommend