You have two good options to save this value.
TerminalGlobalVariables
A custom object on the chart.
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
In MT4, the _UninitReason survives the change of periods, and it has the value of 3, as per the documentation, which is useful to change the behavior of an indicator.
In MT5, the reason is erased.
here is the log of this indicator which prints only the Reasons. The doc says when the period is changed,
https://www.mql5.com/en/docs/constants/namedconstants/uninit
_UninitReason
must be 3, but it's 0 when the indicator is relaunched, and so it's useless.
2021.12.26 18:24:53.061 _UNINIT (GBPUSD,M5) OnInit 0 0 5
2021.12.26 18:24:53.061 _UNINIT (GBPUSD,M5) OnCalculate 0 0 5
2021.12.26 18:24:53.656 _UNINIT (GBPUSD,M5) OnCalculate 0 0 5
2021.12.26 18:24:58.694 _UNINIT (GBPUSD,M5) OnDeinit_Uninitalization reason code = 3
2021.12.26 18:24:58.694 _UNINIT (GBPUSD,M5) OnDeinit_UninitReason = Symbol or timeframe was changed
2021.12.26 18:24:58.704 _UNINIT (GBPUSD,M15) OnInit 0 0 15
2021.12.26 18:24:58.704 _UNINIT (GBPUSD,M15) OnCalculate 0 0 15
2021.12.26 18:24:58.704 _UNINIT (GBPUSD,M15) OnCalculate 0 0 15
In MT4, the log is this
2021.12.26 18:28:50.193 Custom indicator _UNINIT EURUSD,M1: loaded successfully
2021.12.26 18:28:51.351 _UNINIT EURUSD,M1: OnInit 0 0 1
2021.12.26 18:28:51.351 _UNINIT EURUSD,M1: initialized
2021.12.26 18:28:51.351 _UNINIT EURUSD,M1: OnCalculate 0 0 1
2021.12.26 18:28:54.146 _UNINIT EURUSD,M1: uninit reason 3
2021.12.26 18:28:54.146 _UNINIT EURUSD,M1: OnDeinit_Uninitalization reason code = 3
2021.12.26 18:28:54.146 _UNINIT EURUSD,M1: OnDeinit_UninitReason = Symbol or timeframe was changed
2021.12.26 18:28:54.146 _UNINIT EURUSD,M5: OnInit 3 3 5
2021.12.26 18:28:54.146 _UNINIT EURUSD,M5: initialized
2021.12.26 18:28:54.228 _UNINIT EURUSD,M5: OnCalculate 3 3 5
2021.12.26 18:28:54.233 _UNINIT EURUSD,M5: OnCalculate 3 3 5
2021.12.26 18:28:54.239 _UNINIT EURUSD,M5: OnCalculate 3 3 5
2021.12.26 18:28:54.245 _UNINIT EURUSD,M5: OnCalculate 3 3 5
2021.12.26 18:28:54.246 _UNINIT EURUSD,M5: OnCalculate 3 3 5
2021.12.26 18:28:54.313 _UNINIT EURUSD,M5: OnCalculate 3 3 5
2021.12.26 18:28:54.316 _UNINIT EURUSD,M5: OnCalculate 3 3 5
2021.12.26 18:28:54.316 _UNINIT EURUSD,M5: OnCalculate 3 3 5