- Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6.
- Questions from Beginners MQL4 MT4 MetaTrader 4
- why does this doesn't do trades?
Because only the current balance is maintained by the system. All the rest have to be either calculated from history, or kept as a variable in the running code.
When you change time-frame or symbol on the chart, the Indicator is reset or restarted, so all variables are reinitialised and their previous values lost.
The indicator would have to be changed to keep track of such values in a more permanent way so that they could survive the re-initialisation process.
Do you know how I could do it with the current balance?
Is there a link that explains it? (I haven't been able to find it on the net).
The current balance is the current balance. That is always available by the system:
printf( "Account Balance: %G", AccountInfoDouble( ACCOUNT_BALANCE ) );
Show your code if you want further guidance with the rest:
Oh, sorry, that's obvious. Excuse the ignorance.
Thanks Fernando.
The solution with terminal global variables
#include <CGlobalVar.mqh> //Para poner Balance0 como variable de terminal int OnInit() { if(GlobalVariableCheck("Balance0_value")==true) Balance0=GlobalVariableGet("Balance0_value"); else{ CGlobalVar Balance0_value;//Para reservar el valor en el cambio de timeframe Balance0_value.Create("Balance0_value",Balance0,true) ; } ....... } void OnDeinit(const int reason) { ....... GlobalVariableSet("Balance0_value", Balance0); ....... }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use