Translate piece of Mt4 code to Mt5 pls

 

Im trying to make the simple moving average cross as a practise ea on mt5. Im confused as to how to select previous bars on the indicator.

 

heres the mt4 code of what im trying to do on mt5

double previousfast = iMA(NULL,0,fastma,fastmashift,fastmamethod,fastmaappliedto,2);
double currentfast = iMA(NULL,0,fastma,fastmashift,fastmamethod,fastmaappliedto,1);

double previousslow = iMA(NULL,0,slowma,slowmashift,slowmamethod,slowmaappliedto,2);
double currentslow = iMA(NULL,0,slowma,slowmashift,slowmamethod,slowmaappliedto,1);



if(previousfast<previousslow && currentfast>currentslow)

{



if(OrderSend(Symbol(),OP_BUY,lotsize,Ask,3,Ask-(stoploss),Ask+(takeprofit),"Two Moving Average Crossover EA Trade",magicnumber,0,Green)==-1)
Print(GetLastError());
  

}

  if (previousfast>previousslow && currentfast<currentslow)

{

  
      
if (OrderSend(Symbol(),OP_SELL,lotsize,Bid,3,Bid+(stoploss),Bid-(takeprofit),"Two Moving Average Crossover EA Trade",magicnumber,0,Red)==-1)
Print(GetLastError());
}

 so how do i get the iMA on MT5 to look at previous bars like this one does?

 
You can get the general idea from here - https://www.mql5.com/en/articles/81
Migrating from MQL4 to MQL5
Migrating from MQL4 to MQL5
  • 2010.05.17
  • Sergey Pavlov
  • www.mql5.com
This article is a quick guide to MQL4 language functions, it will help you to migrate your programs from MQL4 to MQL5. For each MQL4 function (except trading functions) the description and MQL5 implementation are presented, it allows you to reduce the conversion time significantly. For convenience, the MQL4 functions are divided into groups, similar to MQL4 Reference.
 
ReillyFox:

Im trying to make the simple moving average cross as a practise ea on mt5. Im confused as to how to select previous bars on the indicator.

 

heres the mt4 code of what im trying to do on mt5

double previousfast = iMA(NULL,0,fastma,fastmashift,fastmamethod,fastmaappliedto,2);
double currentfast = iMA(NULL,0,fastma,fastmashift,fastmamethod,fastmaappliedto,1);

double previousslow = iMA(NULL,0,slowma,slowmashift,slowmamethod,slowmaappliedto,2);
double currentslow = iMA(NULL,0,slowma,slowmashift,slowmamethod,slowmaappliedto,1);



if(previousfast<previousslow && currentfast>currentslow)

{



if(OrderSend(Symbol(),OP_BUY,lotsize,Ask,3,Ask-(stoploss),Ask+(takeprofit),"Two Moving Average Crossover EA Trade",magicnumber,0,Green)==-1)
Print(GetLastError());
  

}

  if (previousfast>previousslow && currentfast<currentslow)

{

  
      
if (OrderSend(Symbol(),OP_SELL,lotsize,Bid,3,Bid+(stoploss),Bid-(takeprofit),"Two Moving Average Crossover EA Trade",magicnumber,0,Red)==-1)
Print(GetLastError());
}

 so how do i get the iMA on MT5 to look at previous bars like this one does?

Is it that hard to read the documentation ?

After months seeing you trying to get something with mql5, I would suggest you, kindly, to stop wasting your time and hire someone to get what you want.

 
Alain Verleyen:

Is it that hard to read the documentation ?

After months seeing you trying to get something with mql5, I would suggest you, kindly, to stop wasting your time and hire someone to get what you want.

I have read the documentation and it does not answer the question. Or maybe it does and I have missed it/ dont understand it.

This is the part where you either clarify/ go into detail about answering my question, or piss off.

Im trying to learn the code and I WILL learn the code so either make your comments usefull or take your stuck up attitude somewhere else. 

 
Alain Verleyen:

Is it that hard to read the documentation ?

After months seeing you trying to get something with mql5, I would suggest you, kindly, to stop wasting your time and hire someone to get what you want.

and that second link you added was a question about when i was learning mt4. which ive learnt the basics of that but i thought mt5 would be better because its newer.

 

you really are a pessimist. 

 
ReillyFox:

I have read the documentation and it does not answer the question. Or maybe it does and I have missed it/ dont understand it.

This is the part where you either clarify/ go into detail about answering my question, or piss off.

Im trying to learn the code and I WILL learn the code so either make your comments usefull or take your stuck up attitude somewhere else. s

The question was :  

 so how do i get the iMA on MT5 to look at previous bars like this one does?

I correctly and usefully said you to read the documentation, I provided you a link, and I gave you an opinion. You are free to dislike it, but you will have to stay correct and respectful and avoid any strong language.

The documentation about iMA for MT5 is very complete, even providing a full example source code. So if it doesn't help, show us your mql5 attempt and ask your question about what is not clear.

Reason: