price
You code is incomplete and won't compile. What is the "price"?
string price; int OnInit() { Print(GlobalVariableCheck(price)); if(!GlobalVariableCheck(price))GlobalVariableSet(price,0); Print(GlobalVariableCheck(price)); return(INIT_SUCCEEDED); }
sorry missed out the string declaration
You are not checking the return value for the function GlobalVariableSet to see if it succeeds or fails, nor are you checking the error status if it fails.
Return Value
If successful, the function returns the last modification time, otherwise 0. For more details about the error, call GetLastError()
Your sample code also does not assign any name to the "price" string variable, so it will always fail due it being an empty string.
string price = "variable name"; // Give the Global Terminal Variable a name

- docs.mql4.com
You are not checking the return value for the function GlobalVariableSet to see if it succeeds or fails, nor are you checking the error status if it fails.
Your sample code also does not assign any name to the "price" string variable, so it will always fail due it being an empty string.
it doesn't matter if you assign string price = 0; no difference.
i am checking return value - please see the 'false' print statements!
name = price (a string)
value = 0
it doesn't matter if you assign string price = 0; no difference.
i am checking return value - please see the 'false' print statements!
name = price (a string)
value = 0
No, you are NOT doing any of the things I outlined in my post. Read it again carefully and correct your code accordingly.
After the changes, post your new code if it is still not working for you.
I have no idea what you are talking about - please stop wasting my time.
if you have a better solution ( for 4 lines of code) just say it stop trying to be clever!
I have no idea what you are talking about - please stop wasting my time.
if you have a better solution ( for 4 lines of code) just say it stop trying to be clever!
See Checking the existence of a variable at:
MQL5 Programming Basics: Global Variables of the MetaTrader 5 Terminal
Dmitry Fedoseev, 2016.11.25 13:11
Global variables of the terminal provide an indispensable tool for developing sophisticated and reliable Expert Advisors. If you master the global variables, you will no more be able to imagine developing EAs on MQL5 without them.Pay attention to MathMin().

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Print statement output.
Has anybody seen this before?
OK..please let me know what I am doing wrong?
thanks.