How to make OnTimer in an indicator stop working when the account/broker changes, if it does not have such a ticker, or it is not added to market overview, without using IndicatorDelete?
Errata in the documentation - there is no IndicatorDelete function, there is ChartIndicatorDelete!
bool IndicatorDelete(
int sub_win // номер подокнаconststring name // короткое имя индикатора
);
The situation is as follows - I run the attached indicator on the futures. I switch to another broker, but the timer keeps ticking, although the chart becomes black and does not update.
How to make OnTimer in an indicator stop working when the account/broker changes, if it does not have such a ticker, or it is not added to market overview, without using IndicatorDelete?
Errata in the documentation - there is no IndicatorDelete function, there is ChartIndicatorDelete!
The situation is as follows - I run the attached indicator on the futures. I switch to another broker, but the timer keeps ticking, although the chart becomes black and does not update.
closing of the terminal (if an indicator has been attached to a chart)
loading of a template if an indicator is attached to a chart;
close the chart to which the indicator has been attached
profile change, if the indicator is attached to one of the charts of the profile to be changed;
change of the symbol and/or period of the chart, to which the indicator is attached;
change of indicator input parameters.
The reason "change of account" does not exist, it means that the indicator is not unloaded at account switching and consequently OnDeinit() for the indicator, when you change the trading account won't be either.
closing of the terminal (if an indicator is attached to a chart)
loading of a template, if an indicator is attached to the chart
close the chart to which the indicator has been attached
profile change, if the indicator is attached to one of the charts of the profile to be changed;
change of the symbol and/or period of the chart, to which the indicator is attached;
change of indicator input parameters.
The reason "account switch" does not exist, it means that the indicator is not unloaded at account switching and consequently there will be no OnDeinit() for the indicator when you change the trading account.
In fact, the reason I mentioned works only for Expert Advisors.
Коды причины деинициализации эксперта ....
Then the question remains - how to make the timer stop working without radically removing the indicator from the chart?
Стандартные константы, перечисления и структуры / Именованные константы / Причины деинициализации - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
build 1589
How to make OnTimer in an indicator stop working when the account/broker changes, if it does not have such a ticker, or it is not added to market overview, without using IndicatorDelete?
Errata in the documentation - there is no IndicatorDelete function, there is ChartIndicatorDelete!
https://www.mql5.com/ru/docs/standardlibrary/cchart/cchartindicatordelete
The situation is as follows - I run the attached indicator on the futures. I switch to another broker, but the timer keeps ticking, although the chart becomes black and does not update.
it does not write the reason for deinitialization
REASON_ACCOUNT
6
Another account has been activated or reconnection to the trade server due to a change in account settings
build 1589
OnDeinit is not called.
What do you mean? Not called at all, or in this code?
build 1589
How to make OnTimer in an indicator stop working when the account/broker changes, if it does not have such a ticker, or it is not added to market overview, without using IndicatorDelete?
Errata in the documentation - there is no IndicatorDelete function, there is ChartIndicatorDelete!
https://www.mql5.com/ru/docs/standardlibrary/cchart/cchartindicatordelete
The situation is as follows - I run the attached indicator on the futures. I switch to another broker, but the timer keeps ticking, although the chart becomes black and does not update.
it does not write the reason for deinitialization
REASON_ACCOUNT
6
Another account is activated or reconnection to a trade server was caused by a change in the account settings
Loading and unloading of indicators
Indicators are uploaded in the following cases
Indicators are unloaded in the following cases
The reason "change of account" does not exist, it means that the indicator is not unloaded at account switching and consequently OnDeinit() for the indicator, when you change the trading account won't be either.
What do you mean? Not called at all, or in this code?
Loading and unloading indicators
Indicators are unloaded in the following cases
The reason "account switch" does not exist, it means that the indicator is not unloaded at account switching and consequently there will be no OnDeinit() for the indicator when you change the trading account.
In fact, the reason I mentioned works only for Expert Advisors.
Then the question remains - how to make the timer stop working without radically removing the indicator from the chart?
In fact, the reason I mentioned only works for experts
Then the question remains - how to get the timer to stop working without drastically removing the indicator from the chart?
In OnInit() memorize the score. In the timer check the account number. If the score has changed - exit the timer.
Then the question remains - how do you get the timer to stop working without drastically removing the indicator from the chart?
don't you think that's a crooked solution?!
suppose we doACCOUNT_LOGIN!=ACCOUNT_LOGIN_NEW, kill the timer, and then go back to this account, what happens? the timer will not start again?
it is easier to add the reason "change of account" to the indicators in the same way, or am i wrong in some way and it will lead to some difficulties?
you have to admit, it's a crooked solution?!
It's a horse move!
Suppose we doACCOUNT_LOGIN!=ACCOUNT_LOGIN_NEW, kill the timer, and then go back to that count, what happens?
When an account change is detected, you remember the new characteristics already.
You can design it as a small library on the principle that here(macros). Then the "crooked" stuff won't be a nuisance.