Dynamic GLobal Variables

 
Hi

I was wondering what you guys do when running one EA over multiple charts. My EA has global variables and clashes.
How do you guys do this? Can I make a global variable that has a different name every time and how can I do this?

L.
 

over multiple charts?

Why Charts? EA only need attach to one chart, and can trade any of USD EUR JPY.. ....... wky you need multiple charts?

generally, only need data, one can get data no related with charts.

 

"Can I make a global variable that has a different name every time and how can I do this?"

Here is one ugly way

int start()
{


string name1, name2, name3;
int tick;

tick = GetTickCount();
while(tick == GetTickCount());

name1 = "UniqueGlobalName" + "_" + DoubleToStr(TimeLocal(), 0) + "_"+GetTickCount();

tick = GetTickCount();
while(tick == GetTickCount());

name2 = "UniqueGlobalName" + "_" + DoubleToStr(TimeLocal(), 0) + "_"+GetTickCount();

tick = GetTickCount();
while(tick == GetTickCount());

name3 = "UniqueGlobalName" + "_" + DoubleToStr(TimeLocal(), 0) + "_"+GetTickCount();

GlobalVariableSet(name1, value1);

GlobalVariableSet(name2, value2);

GlobalVariableSet(name3, value3);


return(0);
}

* Sleep(1) was my first choice to waste at least one millisecond, it doesn't work

 
Thank you very much for answers. DxdCN very interesting, I think I will Try that Sometime. But I think you would still have to create alot of variables for each one.

I dunno how to attach that variable in mql4
name1_lastprice=GlobalVariableGet("name1_lastprice");
want that to be unique_lastprice=GlobalVariableGet("unique_lastprice");

Is this possible?

Another Solution:
I thought of deleting all the variables at different time intervals but think this will still clash.
 

What do you want to do with these global variables?

Maybe write data to a file and read from it instead if you need some persistent data or data shared between EAs.

The reply above was to create a unique "name" which can be used to create a unique GlobalVariable. I edited
the reply there to show assignment to GlobalVariable. I originally got sidetracked when i found out Sleep() doesn't
work exactly as advertised.

 
Thanks thats what I needed. I decided Im fed up with Strategy tester and wrote all data to mysql.
Reason: