Navigation´╝ÜHome > Content >

KRSI.mq4

Time: 2018-10-22 | Download file:KRSI.mq4

//+------------------------------------------------------------------+
//|                                                         KRSI.mq4 |
//|                                                          Kalenzo |
//|                                      bartlomiej.gorski@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link      "bartlomiej.gorski@gmail.com"

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 DodgerBlue
#property indicator_color2 Green
#property indicator_color3 Red
#property indicator_color4 White // Set this color to your background color
#property indicator_color5 Red
#property indicator_color6 Magenta
#property indicator_color7 DodgerBlue
#property indicator_color8 Blue

#property indicator_maximum 100
#property indicator_minimum 0

//---- input parameters
extern int       KPeriod=21;
//---- buffers
double RSIBuffer[];
double hup[];
double hdn[];
double empty[];



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(4);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(0,RSIBuffer);
   
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_DOT,1);
   SetIndexBuffer(1,hup);
   SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_DOT,1);
   SetIndexBuffer(2,hdn);
   
   SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_DOT,1);
   SetIndexBuffer(3,empty);
   
   IndicatorShortName("K RSI");
  
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   drawLabel();
   SetLevelValue(0,20);
   SetLevelValue(1,30);
   SetLevelValue(2,50);
   SetLevelValue(3,70);
   SetLevelValue(4,80);
   
   SetLevelStyle(STYLE_DOT,1,Black) ;
   
   int counted_bars = IndicatorCounted();
   if(counted_bars<0) counted_bars=0;
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
//----
   for(int i=limit;i>=0;i--)
   {
      double rsiv = iRSI(NULL,0,KPeriod,PRICE_CLOSE,i);
      RSIBuffer[i] = rsiv;
       
       if(rsiv>50)  
       {
         hup[i] = rsiv;
         hdn[i] = 50.00;
         empty[i] = 50.00;
       }
       else
       {
         hup[i] = rsiv;
         hdn[i] =50.00 ; 
         empty[i] = rsiv;        
       }
   }
   
  
//----
   return(0);
  }
//+------------------------------------------------------------------+

void drawLabel()
{
    
     
        ObjectCreate("KLabelRSI", OBJ_LABEL, WindowFind("K RSI") , 0, 0);
        ObjectSetText("KLabelRSI","Kale Workshop", 15, "Arial", EMPTY);
        ObjectSet("KLabelRSI", OBJPROP_COLOR, DodgerBlue);
        ObjectSet("KLabelRSI", OBJPROP_CORNER, 0);
        ObjectSet("KLabelRSI", OBJPROP_XDISTANCE, 5);
        ObjectSet("KLabelRSI", OBJPROP_YDISTANCE, 20);
        
        ObjectCreate("InameRSI", OBJ_LABEL, WindowFind("K RSI"), 0, 0);
        ObjectSetText("InameRSI","Kale RSI", 8, "Arial", EMPTY);
        ObjectSet("InameRSI", OBJPROP_COLOR, DodgerBlue);
        ObjectSet("InameRSI", OBJPROP_CORNER, 0);
        ObjectSet("InameRSI", OBJPROP_XDISTANCE, 6);
        ObjectSet("InameRSI", OBJPROP_YDISTANCE, 41); 
    
}

Recommend