That is because OnInit() is called before the account info has had a chance to load.
I have never tried putting IndicatorShortName() anywhere but OnInit() but you could try it after a few new ticks arrive in OnCalculate() or in OnTimer().
Other than that, just change the chart time-frame and then change it back and that will re-initialize the indicator.
I solved putting all initialization inside OnStart()
Andrea Pasquini:
I solved putting all initialization inside OnStart()
I solved putting all initialization inside OnStart()
Indicators do not use OnStart(), Scripts use that.
I don't think that it would be a good idea to have the initialization run every tick when you only need to check IndicatorShortName() .
It's for the name, I need this information in all part in my indicator...so what you suggest?... I use it to initialize some variables.....

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 everyone
Using the code above, if I insert indicator in chart it works correctly, when I close and reopen MT4, the indicator display balance 0, I must delete indicator and re-insert it into the chart...
How I can fix it?
it make the same with
AccountCurrency()
AccountLeverage()
MarketInfo(Symbol(),MODE_MARGINREQUIRED)