Create a Variable based on Symbol

To add comments, please log in or register
Welwitschia Mirabilis
242
Welwitschia Mirabilis  

Hi there.

I am new to mql4 programming and been read some books and tutorials but the easiest way to get the things done is with your precious help.

I need to create a variable (in fact a global variable) that is based on symbol where the indicator is attached.

That way I will be able to use the indicator in several pairs without having to re-code the indicator for each pair.


The idea is:

- Create/Check/Set value of a variable based on currency symbol.


For instance: The indicator is on EUR-USD pair.

The indicator code creates a global variable named "PAIR"_variable_name. In this case EURUSD_variable_name.

If attached on USD-CHF, should be "PAIR"_variable_name. In this case USDCHF_variable_name.


Thank you very much


Regards


Paulo

Bogdan Caramalac
761
Bogdan Caramalac  
GlobalVariableSet(StringConcatenate(Symbol(),"_myvarname"), whatever_value_I_assign_here);
Welwitschia Mirabilis
242
Welwitschia Mirabilis  

Hi TheEconomist,


Thank you very very much


Regards

Paulo

Ray
2646
Ray  
Symbol() returns the name of the pair on the chart the indicator/script/EA is attached to
To add comments, please log in or register