If you use GlobalVariableTemp() they will be automatically deleted when the terminal closes.
If you use GlobalVariableTemp() they will be automatically deleted when the terminal closes.
how can i do it?
how can i run this script everytime MT4 starts or closes?
Remember my robot is already running. Thanks for your support.
i found this script too.
//-------------------------------------------------------------------- // deleteall.mq4 // The program is intended to be used as an example in MQL4 Tutorial. //-------------------------------------------------------------------- int start() // Special start() function { GlobalVariablesDeleteAll(); // Deleting of all GVs PlaySound("W2.wav"); // Sound return; // Exit } //--------------------------------------------------------------------
This code can be added to your EA to delete all your global variables every hour, and whenever the EA gets initialized (i.e. when the terminal starts).
#property strict int OnInit() { // your normal code EventSetTimer(1); OnTimer(); return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { // your normal code EventKillTimer(); } void OnTick() { // your normal code } void OnTimer() { static int LastHour = -1; int ThisHour=Hour(); if(LastHour!=ThisHour) { GlobalVariablesDeleteAll(); LastHour=ThisHour; } }
This code can be added to your EA to delete all your global variables every hour, and whenever the EA gets initialized (i.e. when the terminal starts).
thank you for your answer but I don't have access of the EA. The EA is not mine.
Is there another way? something i can add when MT4 starts and make loop with GlobalVariablesDeleteAll
thank you for your answer but I don't have access of the EA. The EA is not mine.
Is there another way? something i can add when MT4 starts and make loop with GlobalVariablesDeleteAll
You can write your own indicator or EA (that code above is a complete EA if required) that does the above. Just make sure it is applied to a chart in your terminal and it will delete all GVs.
But please heed GumRai's warning. You could well break something in your other EAs and/or indicators.
Then it may not be a good idea to delete the GVs. The EA may not work properly if they are deleted
You can write your own indicator or EA (that code above is a complete EA if required) that does the above. Just make sure it is applied to a chart in your terminal and it will delete all GVs.
But please heed GumRai's warning. You could well break something in your other EAs and/or indicators.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
How can I clear my MT4 from global variables automatically everytime MT4 starts or every hour?
thanks
Ricardo.