Download MetaTrader 5

[Indicator] Where the best place to put the global variables? Inside init(){...} or outside the function??

To add comments, please log in or register
Musngi
299
Musngi  

Where the best place to put the global variables? Inside init(){...} or outside the function?? My variables will used in many functions repeatedly. 

I want to know the best way and efficiently to create indicator. 

whroeder1
15331
whroeder1  
If they are declared inside a function they are local to the function, not global.
Musngi
299
Musngi  
WHRoeder:
If they are declared inside a function they are local to the function, not global.
init() function is initialization, it sounds like global to me. I tried to put global variable in init() function but MQL gave me a warning. 
Keith Watford
Moderator
10372
Keith Watford  
Musngi:
init() function is initialization, it sounds like global to me. I tried to put global variable in init() function but MQL gave me a warning. 
WHRoeder:
If they are declared inside a function they are local to the function, not global.
To add comments, please log in or register