Navigation:Home > Content >

FXG_iRSI_Histogramm.mq4

Time: 2014-04-07 | Download file:FXG_iRSI_Histogramm.mq4

//+------------------------------------------------------------------+
//|                                          FXG_iRSI_Histogramm.mq4 |
//|                                            Dmitry Zhebrak,© 2010 |
//|                                        http://www.fxgeneral.com  |
//+------------------------------------------------------------------+
#property copyright "Dmitry Zhebrak aka Necron,© 2010"
#property link      "http://www.fxgeneral.com/"

#property indicator_separate_window
#property  indicator_buffers 4
#property indicator_color1 Gray
#property indicator_color2 Red
#property indicator_color3 Lime
#property indicator_color4 Red

extern int _Period=8;
extern double Signal_Period=8;
extern bool Colorfull=false;
extern bool show_bar=false;


double RSI_Buffer[];
double Signal_Buffer[];
double RSI_UP[];
double RSI_DN[];

double k; // коэфф. EMA
double rt; // дробная часть периода
int per; // целая часть периода


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
if(Colorfull)
 {
   SetIndexStyle(0,DRAW_HISTOGRAM,CLR_NONE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexStyle(3,DRAW_HISTOGRAM);
 }
else 
 {
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_NONE);
   SetIndexStyle(3,DRAW_NONE);

 } 
IndicatorDigits(2);

SetIndexBuffer(0,RSI_Buffer);
SetIndexBuffer(1,Signal_Buffer);
SetIndexBuffer(2,RSI_UP);
SetIndexBuffer(3,RSI_DN);

IndicatorShortName("iRSI ("+_Period+"),Signal ("+DoubleToStr(Signal_Period,2)+")");
SetIndexLabel(0,"RSI");
SetIndexLabel(1,"Signal_RSI");
SetIndexLabel(2,NULL);
SetIndexLabel(3,NULL);

   per=MathFloor(Signal_Period);
   rt=Signal_Period-per;
   k=2.0/(1+Signal_Period);

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int  i,limit,limit1,limit2, counted_bars=IndicatorCounted();
    limit=Bars-counted_bars;
    limit1=limit;
    limit2=limit1;
//----
   if(counted_bars>0) counted_bars--;
    for(i=limit;i>=0;i--)
     {
      RSI_Buffer[i]=iRSI(Symbol(),Period(),_Period,PRICE_WEIGHTED,i)-50;
     }
    for(i=limit1;i>=0;i--)
     {
      Signal_Buffer[i]=k*RSI_Buffer[i]+(1-k)*Signal_Buffer[i+1];   
     //Signal_Buffer[i]=iMAOnArray(RSI_Buffer,0,Signal_Period,0,MODE_EMA,i);
     }
    for(i=limit2;i>=0;i--)
     {
      if(RSI_Buffer[i]>RSI_Buffer[i+1])
       {
        RSI_UP[i]=RSI_Buffer[i];
        RSI_DN[i]=0;
       }
      else 
       {
        RSI_UP[i]=0;
        RSI_DN[i]=RSI_Buffer[i];
       } 
     } 
//----
   return(0);
  }
//+------------------------------------------------------------------+

Recommend