Download MetaTrader 5

MQL and math equations

To add comments, please log in or register
keltrem
303
keltrem  

New to the world of Metatrader and do not have a good understanding of the power of capabilities of MQL.

Is MQL capable of calculating a value using a semi complex mathematical formula or an equation that needs to calculate variables?


Thanks for your advice

Alain Verleyen
Moderator
32406
Alain Verleyen  
keltrem:

New to the world of Metatrader and do not have a good understanding of the power of capabilities of MQL.

Is MQL capable of calculating a value using a semi complex mathematical formula or an equation that needs to calculate variables?


Thanks for your advice

Probably, but you need a math library for that. See if this one https://www.mql5.com/en/code/1146 meets your needs.
ALGLIB - Numerical Analysis Library
ALGLIB - Numerical Analysis Library
  • votes: 33
  • 2012.10.12
  • Сергей Бочканов
  • www.mql5.com
ALGLIB math function library (v. 3.5.0) ported to MQL5.
Simon Gniadkowski
Moderator
18024
Simon Gniadkowski  
keltrem:

New to the world of Metatrader and do not have a good understanding of the power of capabilities of MQL.

Is MQL capable of calculating a value using a semi complex mathematical formula or an equation that needs to calculate variables?

Can you be a little more specific and absolute ?  linear equations are complex to some people but not others . . .  there are some Maths functions
keltrem
303
keltrem  
RaptorUk .Thanks for directing me to the maths functions. It appears I will be able to have what I want coded. As it is a maths formula would I be better to specify that a coder has a maths background?
Simon Gniadkowski
Moderator
18024
Simon Gniadkowski  
keltrem:
RaptorUk .Thanks for directing me to the maths functions. It appears I will be able to have what I want coded. As it is a maths formula would I be better to specify that a coder has a maths background?
If a coder is selling his/her services you should expect them to be familiar with the majority of available standard functions . . .  if you give a little more detail about what it is you are trying to do we might be able to give an indication of how easy or hard it is to do with mql5.
keltrem
303
keltrem  

What I want to be able to calculate is when a MA and WMA will be exactly the same price during the current bar ie the precursor to a cross. My maths is a little rusty but I believe the equation looks like this on MA40 and WMA5


MA = (CP1,39 + P)/40

WMA = ((CP4*1)+(CP3*2)+(CP2*3)+(CP1*4)+(P*5))/15

Find

MA =WMA

Value to be determined is P

CP are close prices

Is this within the scope of MQL's capabilities and how would this be best coded?

Thanks,


Noel

Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Price Constants
Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Price Constants
  • www.mql5.com
Standard Constants, Enumerations and Structures / Indicator Constants / Price Constants - Documentation on MQL5
Simon Gniadkowski
Moderator
18024
Simon Gniadkowski  
keltrem:

What I want to be able to calculate is when a MA and WMA will be exactly the same price during the current bar ie the precursor to a cross. My maths is a little rusty but I believe the equation looks like this on MA40 and WMA5

This is certainly pretty simple to do for someone that has some experience with mql5,  the issue I see is that using a still forming bar,  bar 0, you can have the MAs cross and uncross several times giving you signals both ways.  If that is what you want it can be done with mql5. 
keltrem
303
keltrem  

Yes i am aware of the MAs propensity to cross and uncross, the EA deals with that. I was more interested to know is a maths equation the best way to determine the price that MA = WMA in the current bar or is there another method of calculating the same thing?

Additionally is it possible to form this equation in MQL where average periods can be modified by a parameter? For example go from MA40 to MA30

Alain Verleyen
Moderator
32406
Alain Verleyen  
keltrem:

Yes i am aware of the MAs propensity to cross and uncross, the EA deals with that. I was more interested to know is a maths equation the best way to determine the price that MA = WMA in the current bar or is there another method of calculating the same thing?

Additionally is it possible to form this equation in MQL where average periods can be modified by a parameter? For example go from MA40 to MA30

You already get the response several times. Yes it's possible with mql5. But you have to provide some efforts to learn how to do it, I doubt someone will give you the code you asked for. If you don't want to code it yourself you can also try the Job service or search the codebase for existing code.
Simon Gniadkowski
Moderator
18024
Simon Gniadkowski  
keltrem:

Yes i am aware of the MAs propensity to cross and uncross, the EA deals with that. I was more interested to know is a maths equation the best way to determine the price that MA = WMA in the current bar or is there another method of calculating the same thing?

Additionally is it possible to form this equation in MQL where average periods can be modified by a parameter? For example go from MA40 to MA30

Yes,  iMA()
keltrem
303
keltrem  
Many thanks for this information RaptorUK, it make the EA spec that much easier
To add comments, please log in or register