Questions from Beginners MQL5 MT5 MetaTrader 5 - page 967
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
How do I get the opening price of a bar right and if I fail to get the opening price to exit?
Sketched out a few options. But maybe there is a better and more correct code?
How do I get the opening price of a bar right and if I fail to get the opening price to exit?
Sketched out a few options. But maybe there is a better and more correct code?
The iXXXX functions only make sense if you are running a one-time request, without loops and without calling any other iXXXX functions.
If you only need to get the opening price once, then seeiOpen's help:
Return value
*** 0 in case of error.
So you need to query the price and check if it is zero: if it is not zero then the price is received, if it is zero then it is an error.
enum Symboll_ { AUDUSD=0, NZDUSD=1, USDCAD=2, USDCHF=3, USDJPY=4, EURJPY=5, EURUSD=6, GBPUSD=7, #CL =8 };
The iXXXX functions only make sense if you are running a one-time request, without cycles and without calling any other iXXXX functions.
If you only need to get the opening price once, seeiOpen help:
Return value
*** 0 in case of error.
So you need to query the price and check that it is zero: if it is not zero then the price is received, if it is zero then it is an error.
Thank you. One more question. Should we use parentheses in this code or it makes no difference?
Can you please tell me how to insert the 9 parameter with a grid (#CL) so that the compiler doesn't generate an error?
Like this:
Thank you. One more question. Should brackets be used in this code or does it make no difference?
It will do. Generally speaking, brackets are intended for a group of actions. If there is only one action, they are of no use.
There you go:
Thank you very much!
Because I tried it like this and it didn't work:
Thank you very much!
Because I tried it like this and it didn't work:
Or like this:
or this:
That's the one!
In those variants it came out either just a serial number orSIM_1,...etc.