Converting MQL4 RSI and MACD to MQL5

 

I would be very grateful if someone could help me with converting the RSI and MACD below to mql5. I have seen an article on the forum on converting mql4 code to mql5 which has helped me in some other cases but I don't seem to get how to do it for the RSI and MACD. Please see the code below:


 if((iMACD(NULL,PERIOD_M5,12,26,9,PRICE_CLOSE,mode_main,0)<iMACD(NULL,PERIOD_M5,12,26,9,PRICE_CLOSE,mode_signal,0))&&(iRSI(NULL,PERIOD_M5,2,PRICE_CLOSE,0)<16)) 
     {
      //do something
}
 
  1. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum

  2.       handle=iRSI(name,period,ma_period,applied_price);
    ⋮
       if(CopyBuffer(ind_handle,0,0,amount,rsi_buffer)<0)
    
    What part of the example code of getting a handle in OnInit and then using it In OnCalculate to get values, was unclear?
              Technical Indicators / iRSI - Reference on algorithmic/automated trading language for MetaTrader 5
 
Jackery:

I would be very grateful if someone could help me with converting the RSI and MACD below to mql5. I have seen an article on the forum on converting mql4 code to mql5 which has helped me in some other cases but I don't seem to get how to do it for the RSI and MACD. Please see the code below:


Mql5 gives you low level access to data, but it's really meant to be used with the standard library and OOP. In MQL5 you'd want to instantiate a CIndicators collection and add your new dynamically allocated indicator objects to it. All the heavy code bits are handled on the initialization then you save multiples of time once you get to coding the algorithms. 

#include <indicators/indicators.mqh>

CIndicators g_indicators;
CiRSI       *g_rsi;
CiMACD      *g_macd;

int OnInit() {
   g_rsi = new CiRSI();
   g_indicators.Add(g_rsi);
   g_macd = new CiMACD();
   g_indicators.Add(g_macd);
   bool is_init = g_rsi.Create(_Symbol, PERIOD_M5, 2, PRICE_CLOSE);
   is_init &= g_macd.Create(_Symbol, PERIOD_M5, 12, 26, 9, PRICE_CLOSE);
   return is_init ? INIT_SUCCEEDED : INIT_FAILED;
}

void OnTick() {
   g_indicators.Refresh();
   if (g_macd.Main(0) < g_macd.Signal(0) && g_rsi.Main(0) < 16) {
      Print("Signal!");
   }
}
 
nicholi shen:

Mql5 gives you low level access to data, but it's really meant to be used with the standard library and OOP. In MQL5 you'd want to instantiate a CIndicators collection and add your new dynamically allocated indicator objects to it. All the heavy code bits are handled on the initialization then you save multiples of time once you get to coding the algorithms. 

Thank you Sir, I really appreciate the help.

 
Hi Friends
Hope you all are fine. i need your guidance please? How can we install Tradional MACD for MT4 on android app? CAn anyone guide me please? i will be highly grateful.
 
Hi everybody I need assistance in getting my money back into my traiding account  ,I have transferred money into the wrong metadrader4 and I can not get it back I just wanna know what to do I'm still new 
 
Kedibone Kid-fresh:
Hi everybody I need assistance in getting my money back into my traiding account  ,I have transferred money into the wrong metadrader4 and I can not get it back I just wanna know what to do I'm still new 

Hi you have to contact your broker for that.

Reason: