Alain Verleyen:
1° There is no need to terminate the indicator, just "return" without doing anything and it will do nothing anyway.
2° To remove an indicator from the chart, use ChartIndicatorDelete().
Thank you Alain. When you put it in those terms, it makes sense! :) Cheers.

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
Hi there,
I have a password validation class that uses the AccountInfoInteger(ACCOUNT_LOGIN) to compare with an encrypted input parameter (loosely based on https://www.mql5.com/en/code/15534). This call is made in the OnInit function in the Indicator. If it legitimately doesn't validate, I return INIT_FAILED from OnInit and the Indicator doesn't load, as required and expected. This works absolutely fine when you drop the indicator on an already loaded chart in MT4.
However, when starting MT4 for the first time where the Indicator is already on the chart, the call to AccountInfoInteger(ACCOUNT_LOGIN) returns 0 (zero) because at that point, MT4 hasn't connected to the Broker's server (IsConnected() returns false). I've tried a few different approaches to "slow" down this process but nothing works.
In OnCalculate, I am guaranteed the connection has occurred so I could conditionally load the security class in OnCalculate. However, if the validation fails, I have no idea how I could terminate the indicator from inside OnCalculate?
So, if anyone can help with one or both of the above issues, I'd be very grateful indeed.
Many thanks :)