Plot Relative slope

To add comments, please log in or register
Manish Chugani
110
Manish Chugani  

Hello,

There is this Relative Slope by Dimitris Tsokakis and am trying to plot it in MT4 but with no luck. Am only able to get the first buffer to plot and not the rest.

Please kindly guide. Thanks !


K=EMA((H+L+C)/3,10);

S1=2*(K-REF(K,-1))/(K+REF(K,-1));

RS=100*EMA(S1,3);

Plot(RS,"RS",colorGrey40,styleLine|styleOwnScale,0,0,0,0,2);

The above four lines of code is all there is for Amibroker Afl. But when the same comes to MQL, it seems so complex.

//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 4
#property  indicator_color1 Green
#property  indicator_color2 Blue
#property  indicator_color3 Yellow
#property  indicator_color4 Red
#property  indicator_width1 1
#property  indicator_width2 1
#property  indicator_width3 1
#property  indicator_width4 1
#property  indicator_style1 STYLE_SOLID
#property  indicator_style2 STYLE_SOLID
#property  indicator_style3 STYLE_SOLID
#property  indicator_style4 STYLE_SOLID

//---- indicator parameters
extern int  EMA_Period     = 10;
extern int  Signal_Period = 3;
extern int  CountBars    = 1500;

//---- indicator buffers
double      ind_buffer1[];
double      ind_buffer2[];
double      ind_buffer3[];
double      ind_buffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   IndicatorBuffers(4);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexStyle(3,DRAW_LINE);
//---- indicator buffers mapping
   SetIndexBuffer(0,ind_buffer1);
   SetIndexBuffer(1,ind_buffer2);
   SetIndexBuffer(2,ind_buffer3);
   SetIndexBuffer(3,ind_buffer4);

//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("EMA index | Period: "+EMA_Period+", Signal Period: "+Signal_Period+" | ");

//---- initialization done
   return(0);
  }

int start()
  {
   if (EMA_Period==Signal_Period) return(0);
   
   int i, limit=CountBars;
   if (limit>Bars) limit=Bars-1;

   for(i=0; i<limit; i++)  {
      ind_buffer1[i]=(High[i]+Low[i]+Close[i])/3;
      ind_buffer2[i]=iMAOnArray(ind_buffer1,0,EMA_Period,0,MODE_EMA,i);
      ind_buffer3[i]=2*(ind_buffer2[i]-ind_buffer2[i+1])/(ind_buffer2[i]+ind_buffer2[i+1]);
      ind_buffer4[i]=100*iMAOnArray(ind_buffer3,0,Signal_Period,0,MODE_EMA,i);
      }
   return(0);
  }


To add comments, please log in or register