Hello, everybody, i am quite new to MQL4 programming, and i have a problem :)
As a result to the coding above, i would like to have a global variable declared when there are no orders opened. But i want my global variable to have the same until it is recalculated (until orderstotal=0) so i can use it when i have to open orders (when orderstotal>0). Instead, when there are no orders, the variable value gets the account ballance value but when there are some orders, it equals to 0, and so the global variable..(so it's useless for me since i want to use the variable value calculated when OrdersTotal()==0.). Can i make the program somehow to memorize the value when the condition is accomplished and then use it later on? Have any idea about any sollution than can solve this problem for me? Thanks and sorry for my bad english, i am not a native speaker :)
Hi 8323, Until reassign new value to it. Actually I'm not sure what you want, so I may be wrong. Write the code like this or just change the type account_ballance variable from local to global.
if(OrdersTotal()==0) { double account_ballance=AccountBalance(); GlobalVariableSet("account ballance(start)", account_ballance); } else { account_ballance=GlobalVariableGet("account ballance(start)"); }
Hi 8323, Until reassign new value to it. Actually I'm not sure what you want, so I may be wrong. Write the code like this or just change the type account_ballance variable from local to global.
Thanks a lot!! This solved my problem :) Have a nice day, guys! :P
- 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, everybody, i am quite new to MQL4 programming, and i have a problem :)
As a result to the coding above, i would like to have a global variable declared when there are no orders opened. But i want my global variable to have the same until it is recalculated (until orderstotal=0) so i can use it when i have to open orders (when orderstotal>0). Instead, when there are no orders, the variable value gets the account ballance value but when there are some orders, it equals to 0, and so the global variable..(so it's useless for me since i want to use the variable value calculated when OrdersTotal()==0.). Can i make the program somehow to memorize the value when the condition is accomplished and then use it later on? Have any idea about any sollution than can solve this problem for me? Thanks and sorry for my bad english, i am not a native speaker :)