Mathematical expression on MQL5

 

How do you put this MQL4 expression in MQL5 language ?

Open[1+i] > (High[1+i] + Low[1+i]) / 2 


I tried  MathAbs(Open[1+i]>(High[1+i]+Low[1+i])/2) but it gives error and cannot compile


Thanks for your inputs.


 
JavierMz:How do you put this MQL4 expression in MQL5 language ? Open[1+i] > (High[1+i] + Low[1+i]) / 2  I tried  MathAbs(Open[1+i]>(High[1+i]+Low[1+i])/2) but it gives error and cannot compile

MT5 works differently! Is this an indicator or an EA?

Depending on the circumstances, there can be many different solutions. Show more code or explain in more detail.

One solution is to use the "i" functions instead but it depends, for example iOpen( _Symbol, _Period, i )

For more information, read the following:

Migrating from MQL4 to MQL5
Migrating from MQL4 to MQL5
  • 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.
 
Fernando Carreiro #:

MT5 works differently! Is this an indicator or an EA?

Depending on the circumstances, there can be many different solutions. Show more code or explain in more detail.

One solution is to use the "i" functions instead but it depends, for example iOpen( _Symbol, _Period, i )

For more information, read the following:

This is for an indicator.

This expression is when the open of the previous candle is above of its middle

 
JavierMz #: This is for an indicator. This expression is when the open of the previous candle is above of its middle

For an Indicator, using the OnCalculate() event handler, you can use the data arrays passed as parameters.

open[ i + 1 ] > ( high[ i + 1 ] + low[ i + 1 ] ) / 2

However, even in MQL4+, this was the correct way to do it. The main difference between the MQL4+ and MQL5 OnCalculate handling is that the array sequencing is reversed, because MQL4+ uses Arrays as a Series and MQL5 uses them as a Non-Series.

Please read up on the links I provided. There are also many other references on the Forum, the CodeBase and the Articles, about converting to MQL5.

 
JavierMz #:

This is for an indicator.

Moved to Technical Indicators section.

 
Fernando Carreiro #:

For an Indicator, using the OnCalculate() event handler, you can use the data arrays passed as parameters.

However, even in MQL4+, this was the correct way to do it. The main difference between the MQL4+ and MQL5 OnCalculate handling is that the array sequencing is reversed, because MQL4+ uses Arrays as a Series and MQL5 uses them as a Non-Series.

Please read up on the links I provided. There are also many other references on the Forum, the CodeBase and the Articles, about converting to MQL5.

Ok, thanks very much

 

If you want an example of an indicator that compiles for both MQL4 and MQL5, so you can study it and see the differences, then have a look at my CodeBase publication:

Dōteki Heikin Ashi (Dynamic Average Foot/Bar)
Dōteki Heikin Ashi (Dynamic Average Foot/Bar)
  • www.mql5.com
A dynamic version of the standard Heikin Ashi indicator (code compatible with both MQL4 or MQL5).
 

Hello everyone. I would appreciate it if you could help me. My question is How is it possible to determine the mathematical function or mathematical formula of a custom indicator??? I mean like the mathematical formula that is available on the internet for Average True Range indicator.

Thank you so much

 
Aydin Ennio #: Hello everyone. I would appreciate it if you could help me. My question is How is it possible to determine the mathematical function or mathematical formula of a custom indicator??? I mean like the mathematical formula that is available on the internet for Average True Range indicator. Thank you so much

By analysing its code!

 
Fernando Carreiro #:

By analysing its code!

Thank you Dearest Mr. Carreiro; I suppose I will have to dedicate a considerable amount of time learning MQL5 programming. 

Reason: