
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
If the timeframe changes if has to reinit to recalculate all bars. You had to see the comment go from 0 to 1. If you refuse to answer questions and perform tests, no one here can help you.
The topic is about changing the account, isn't it. You turned the topic to changing timeframes, and in fact nobody complains about changing timeframes. Now, you are talking about recalculating bars. Do you really believe that recalculating more bars is the remedy for a changed account? When you start the indicator in a demo account, and then the indicator does not register that it has switched to a real account? When the indicator does not notice, that the history folder changed and keeps feeding hst file in an incorrect folder? When your indicator feeds a remote connection and does not notice the account changed? There are a dozen more reasons why you need to register the account change. The question was HOW to register the ACCOUNT CHANGE in an INDICATOR, not quarrelling about global variables in experts or recounting bars. Please accept it.
Hi
too bad that the indicator OnInit is not called when changing accounts.
The problem is that differents brokers are using different CFD symbol names for the same stock index.
So when I switch to another broker and go back to my previous broker, the indicator is not refreshing anymore and get stuck.
I am not sure that it isn't called, but if that is the case, check for it. Is that so hard?
That is not an assignment; it's initialization of a common (globally declared), or static variable with a constant. They work exactly the same way in MT4/MT5/C/C++.
They are initialized once on program load.
They don't update unless you assign to them.
In C/C++ you can only initialize them with constants, and they default to zero. In MTx you should only initialize them with constants. There is no default in MT5, or MT4 with strict (which you should always use).
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: