Marko Tuta #: Hmm, ok. I supposed so. Do you know a way to solve this?
The answer has already been given — "Instead detect when the state changes, either from enabled to disabled, or from disabled to enabled, and set your variables accordingly."
Here is an example I use with MQL5 Services, which checks for multiple conditions and a change in state ...
// Check if trading is allowedbool IsTradingAllowed( void ) {
// Declare and initialise variablesstaticbool s_bAllTradeAllowed = true;
bool bAccountTradeAllowed = AccountInfoInteger( ACCOUNT_TRADE_ALLOWED ),
bAutomatedTradeAllowed = AccountInfoInteger( ACCOUNT_TRADE_EXPERT ),
bTerminalTradeAllowed = TerminalInfoInteger( TERMINAL_TRADE_ALLOWED ),
bProgramTradeAllowed = MQLInfoInteger( MQL_TRADE_ALLOWED ),
bAllTradeAllowed = bAccountTradeAllowed &&
bAutomatedTradeAllowed &&
bTerminalTradeAllowed &&
bProgramTradeAllowed;
// Verify if all trading has been re-enabledif( s_bAllTradeAllowed != bAllTradeAllowed ) {
if( bAllTradeAllowed ) AlertNotify( i_sAttentionEnabled, i_eAlertTradingReenabled );
s_bAllTradeAllowed = bAllTradeAllowed;
};
// Return current trading statusreturn s_bAllTradeAllowed;
};
Ok, I solved. I used the code mentioned above inside the ontick() section on a demo account and it's ok. When I disable EA the variable resets. Thank you for your help
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
The answer has already been given — "Instead detect when the state changes, either from enabled to disabled, or from disabled to enabled, and set your variables accordingly."
Here is an example I use with MQL5 Services, which checks for multiple conditions and a change in state ...