What varable shoud i use?

 

Hello,

i need a little help:

What kind of variable should i use if i need it to be shared in all the symbols on which is EA attached to?

(So for example i need if i set variable)

bool dontTrade = true;

So it will be shared for all the EA instances and no symbol will trade

A little example of usage would be also very useful.

Thanks for help

 

Yep, i am using this kind right now, but it seems to me kind of "hardcore"

It stays 4 weeks saved and so on...

 

one way is:

use global variables - see editor or site docs Global variables

assuming you use function key F3, you could Add a variable named "dontTrade" with a value of 0 or 1 (or actually any zero OR nonZero value to achieve trade OR dontTrade)

All instances of your one EA would be checking (presumably at top of start()) to see if the variable is true (1) or false (0)

The EA code to get the value would be: GlobalVariableGet("dontTrade"); it is a type double function, not type bool but no matter, just give it some non-zero value as said above IF not wanna trade.

NOTE: would also assume that this variable was 'Add'ed via F3 before the EA was run, however if the variable does not exist, the return value is zero meaning the same as 'trade' so you'd soon realise that MUST Add a variable named "dontTrade" with a value of 0 or 1 by using F3

eg:

int start ()

{

if(GlobalVariableGet("dontTrade") != 0) return(0);

.. trade .. or whatever ...

return(0);

}//start()

 

Thats the easiest solutuion for a small comunication between EA's.

You can delete the Globals if you wan't store it 4 weeks.

 

Thanks for help.

I have one more question.

I would like to create master-slave model. (1 master chart) and (all the other charts are slaves)

I should i regonize ex. first attached chart? or how would you solve it?

Thanks

 

Use a file to save and load variables.

 

Also possible with global variables.

in the init. 

int myIdent=0;
if(!GlobalVariableExists("name") ){
   GlobalVariableSet("name",1);
   myIdent=1;
}else{
 GlobalVariableSet("name",GlobalVariableGet("name")+1);
 myIdent=GlobalVariableGet("name");
}


in the deinit you have to decrase the globalvariable. 
Reason: