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.
WHRoeder: 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.
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:
Terminal starts.
Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
OnInit is called.
For indicators OnCalculate is called with any existing history.
Human may have to enter password, connection to server begins.
New history is received, OnCalculate called again.
New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
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: