I want to assign an integer (int) value to a GlobalVariable. Can an integer (int) value be modified to double value before assigned to GlobalVariableSet(), to avoid getting the data conversion warning with GlobalVariableGet() ?? If yes, How?
Assigning to a Global Variable is fine - I don't think converting up from int to double will give a conversion error because there's no potential loss of data. To be absolutely safe about getting the correct int back, I would use MathRound (which also returns a double, something I don't understand), and also explictly typecast to int to avoid the warning.
int nGlobal=(int)MathRound(GlobalVariableGet("Global Integer"));
Assigning to a Global Variable is fine - I don't think converting up from int to double will give a conversion error because there's no potential loss of data. To be absolutely safe about getting the correct int back, I would use MathRound (which also returns a double, something I don't understand), and also explictly typecast to int to avoid the warning.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want to assign an integer (int) value to a GlobalVariable. Can an integer (int) value be modified to double value before assigned to GlobalVariableSet(), to avoid getting the data conversion warning with GlobalVariableGet() ?? If yes, How?