Download MetaTrader 5

iADX values are always 0

To add comments, please log in or register
gadget
102
gadget  

Dear community,

A EA that I have playing with uses the iADX function.

When I debug I have:

iADX (NULL, ADXTime, ADXPeriod, ADXPrice, MODE_PLUSDI, 0) i.e. value of current +DX always returns a value.

iADX (NULL, ADXTime, ADXPeriod, ADXPrice, MODE_PLUSDI, 1) i.e. value of previous +DX always returns a value.

iADX (NULL, ADXTime, ADXPeriod, ADXPrice, MODE_MINUSDI, 0) i.e. value of current -DX always returns a value.

iADX (NULL, ADXTime, ADXPeriod, ADXPrice, MODE_MINUSDI, 1) i.e. value of previous -DX always returns 0!

Any idea on the reason?

The chart clearly displays the ADX lines. Why would MetaTrader return 0?

gadget
102
gadget  
Does someone have any idea? I've been searching around to really no avail.
gadget
102
gadget  
Ok the question didn't trigger tons of suggestions, but just to close the question I found the problem. It was due to the MQL compiler not initializing a local variable. Admins are free to remove this subject if they want.
Alain Verleyen
Moderator
33589
Alain Verleyen  
gadget:
Ok the question didn't trigger tons of suggestions, but just to close the question I found the problem. It was due to the MQL compiler not initializing a local variable. Admins are free to remove this subject if they want.

See documentation :

If a variable is not initialized explicitly, the value stored in this variable can be any. Implicit initialization is not used.

To add comments, please log in or register