Navigation´╝ÜHome > Content >

Inverse_Fisher.mq4

Time: 2016-05-18 | Download file:Inverse_Fisher.mq4

//+------------------------------------------------------------------+
//|                                               Inverse Fisher.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_separate_window
#property indicator_buffers 2

#property indicator_color1 Maroon
#property indicator_color2 CornflowerBlue

#property indicator_level1 0.5
#property indicator_level2 -0.5

#property indicator_levelstyle STYLE_DASH
#property indicator_levelcolor Gold

#property indicator_maximum 1
#property indicator_minimum -1

//---- input parameters
extern int       RSI_Period=5;
extern int       RSI_MA=9;
extern bool      SHOW_RSI=false;
//---- buffers
double RSIval[];
double IF[];
double RSI[];
double WMA[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(4);
   
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,RSIval);

   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,IF);
      
   SetIndexBuffer(2,RSI);   
   SetIndexBuffer(3,WMA); 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectDelete("toplevel");
   ObjectDelete("botlevel"); 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   
   int limit,i;
   
   limit = Bars - counted_bars + 1;
   
   for (i = limit; i>=0; i--)
      {
         RSI[i] = (iRSI(0,0,RSI_Period,PRICE_CLOSE,i)-50.0)/10.0;
         if (SHOW_RSI) RSIval[i] = RSI[i]/5.0;
         else RSIval[i]=EMPTY_VALUE;
      }
   for (i = limit; i>=0; i--)
      {
         WMA[i] = iMAOnArray(RSI,0,RSI_MA,0,MODE_LWMA,i);        
         IF[i] = (MathExp(2.0*WMA[i])-1.0) / (MathExp(2.0*WMA[i])+1.0);
      } 
   if (ObjectFind("toplevel")==-1)
      {
         ObjectCreate("toplevel",OBJ_HLINE,1,1,0.5);
         ObjectCreate("botlevel",OBJ_HLINE,1,1,-0.5);
         ObjectSet("toplevel",OBJPROP_COLOR,Lime);
         ObjectSet("botlevel",OBJPROP_COLOR,Red);
      }
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Recommend