Download MetaTrader 5

Recoding from MQL4 to MQL5

To add comments, please log in or register
strongmann
9
strongmann  

Hello,

could anyone help me with recoding to mql5?

Thanks for any help! 

#property indicator_chart_window
//#property indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color3  Gold
#property  indicator_color1  Green
#property  indicator_color2  Red
#property  indicator_width1 2
#property  indicator_width2 2
#property  indicator_width3 1
double ma[];
double up[];
double dn[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexBuffer(2,ma);
   SetIndexBuffer(0,up);
   SetIndexBuffer(1,dn);
   SetIndexStyle(2,DRAW_NONE);
   SetIndexStyle(0,DRAW_LINE);   
   SetIndexStyle(1,DRAW_LINE);   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   for(int i=0; i<limit; i++)
   {  
   ma[i]=iMA(0,0,10,0,2,0,i);
  
   if (ma[i-1] < ma[i])
      {
       up[i]=ma[i];
       dn[i]=EMPTY_VALUE;
      }
    else 
      {
       dn[i]=ma[i]; 
       up[i]=EMPTY_VALUE;
      }  
    } 
   return(0);
  }
strongmann
9
strongmann  

The biggest problem for me is SetIndexStyle in MQL4 is very simple:

SetIndexBuffer(0,up);
SetIndexStyle(0,DRAW_LINE);   

 There is equally simple solution in MQL5? Thank you

Alain Verleyen
Moderator
29866
Alain Verleyen  
To add comments, please log in or register