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
So? did you try it? does it work if you put it above OnInit?
You should try it yourself. Try and error.
You'll learn faster that way.
Ok, I tested this, it doesn't help. I was curious about what exactly global scope means. It shouldn't be this difficult to add a simple logical OR statement.
I suppose there is always the option of running the working code (the one without the logical OR statement) on 2 seperate EAs on 2 seperate open charts. One for the Low alert the other for the High alert.
MT4/MT5 actually compiles with non-constants, but the order that they are initialized is unspecified and don't try to use any price or server related functions in OnInit (or on load,) as there may be no connection/chart yet:
external static variable - Inflation - MQL4 programming forum
Ok, I tested this, it doesn't help. I was curious about what exactly global scope means. It shouldn't be this difficult to add a simple logical OR statement.
I suppose there is always the option of running the working code (the one without the logical OR statement) on 2 seperate EAs on 2 seperate open charts. One for the Low alert the other for the High alert.
Not necessary. Just use more static/global variables.
Not necessary. Just use more static/global variables.
Hi. Thanks for the code example. Your code has the exact same problem as Ahmad Zuhairdi Noh's code when he added a second price target, it executes an alert immediately instead of waiting for the candle to close.
Hi. Thanks for the code example. Your code has the exact same problem as Ahmad Zuhairdi Noh's code when he added a second price target, it executes an alert immediately instead of waiting for the candle to close.
That's because it's looking at the current price.
Hi. Thanks for the code example. Your code has the exact same problem as Ahmad Zuhairdi Noh's code when he added a second price target, it executes an alert immediately instead of waiting for the candle to close.
Oh, so you want to delay the alert until the candle close even though the price has breach the target?
then you should change Close[0] to Close[1] as suggested by Ernst.
Close[0] means current price while Close[1] is a close price of previous candle.
Oh, so you want to delay the alert until the candle close even though the price has breach the target?
then you should change Close[0] to Close[1] as suggested by Ernst.
Close[0] means current price while Close[1] is a close price of previous candle.
I see.
It's working well now after testing it.
What would be the code for automatically halting the EA once the first alert has been triggered?