if you declare a variable in a function it will only be local to that function.
if you declare it before init() it can be accessed in all functions and will keep its value in between program runs.
I dont use any void, int or other types of secondary functions only the start(), it wont work for start neither because i have bunch of variables in init and they work fine?
Even before i was trying to implement this moving average strategy they worked fine.Actually they were not declared in the init they were declared outside any function only set their values in the init :D
I dont use any void, int or other types of secondary functions only the start(), it wont work for start neither because i have bunch of variables in init and they work fine?
Even before i was trying to implement this moving average strategy they worked fine.Actually they were not declared in the init they were declared outside any function only set their values in the init :D
"Actually they were not declared in the init they were declared outside any function only set their values in the init :D"
Isn't that exactly what I have been saying in all my posts in this thread??
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.
What speculation?
if you declare a variable in a function it will only be local to that function.
if you declare it before init() it can be accessed in all functions and will keep its value in between program runs.
I dont use any void, int or other types of secondary functions only the start(), it wont work for start neither because i have bunch of variables in init and they work fine?
Even before i was trying to implement this moving average strategy they worked fine.Actually they were not declared in the init they were declared outside any function only set their values in the init :D
Ok i resolved the issue, it was hard work.The solution is the following:
An auxiliary variable to which would have the same values as STATUS variable but would be overwritten earlier
And a BUYALLOW and SELLALLOW boolean
and set the
SALLOW=false;after putting the sell order and the
after putting the buy
I dont use any void, int or other types of secondary functions only the start(), it wont work for start neither because i have bunch of variables in init and they work fine?
Even before i was trying to implement this moving average strategy they worked fine.Actually they were not declared in the init they were declared outside any function only set their values in the init :D
"Actually they were not declared in the init they were declared outside any function only set their values in the init :D"
Isn't that exactly what I have been saying in all my posts in this thread??
if you want local variables to retain their values make them static. You could have used static bool flags in the start() function.