in which chart runs an EA

 

Hello

I got many charts opened(USDJPY,GBPUSD,...) at the same time in my mt4 plateforme

In one of this chart ,runs an EA

Visually we can see in which chart it runs

But is it possible programly to know  the chart ID number in which the EA runs between all others

Regards

 
paul selvan:

Hello

I got many charts opened(USDJPY,GBPUSD,...) at the same time in my mt4 plateforme

In one of this chart ,runs an EA

Visually we can see in which chart it runs

But is it possible programly to know  the chart ID number in which the EA runs between all others

Regards

well you could code the ea to send a notification to your phone app or just make a printout in the experts journal every time a new orders is opened with specific details of traded symbol, chart period and so on...

 

the problem is with global variables (GlobalVariableGet, GlobalVariableSet)

Here is :

I've created a global variable "myGlbVar".It has been done in an EA running in usdjpy chart. And it contains its chart number.

datetime t = GlobalVariableSet("myGlbVar",ChartID());

Lets say the chart number of usdjpy is 132302888707960286

I m trying to recover it in an indicator running in another chart

double j = GlobalVariableGet("myGlbVar");

it doesnt give me the right chart number as expected

But either like 132302888707960289  with 3 points different !

Why. And how to get datas from one chart to another one without any false.

usd/jpy - Trading blogs and financial markets analysis
usd/jpy - Trading blogs and financial markets analysis
  • www.mql5.com
The abbreviation for the U.S. dollar and Japanese yen (USD/JPY) pair or cross for the currencies of the United States (USD) and Japan (JPY). The currency pair shows how many Japanese yen (the quote
 
A Double has
15 to 17 significant decimal digits precision (2 −53 ≈ 1.11 × 10 −16). If a decimal string with at most 15 significant digits is converted to IEEE 754 double-precision representation, and then converted back to a decimal string with the same number of digits, the final result should match the original string
          Double-precision floating-point format - Wikipedia, the free encyclopedia

You can't store a long (chart id) with 19 digits. You can split it up, or create a GV who's name includes the id.

Why do you want to? The (only) EA knows its own chart id.

 
William Roeder:

Why do you want to? The (only) EA knows its own chart id.

One chart  (receptor) receiving  ticks from others currency (broadcast)

That's in a multicurrency topics.

For that purpose we need to share the receptor chart id with broadcasters ...programly

 
William Roeder:

 You can  create a GV who's name includes the id.

may you explain more by giving an example

 
#define PREFIX    "myGlbVar"
#define PREFIX_LEN 8

GlobalVariableSet(PREFIX+(string)132302888707960286,0);

long     cid;
for(int i=GlobalVariablesTotal()-1; i>=0; --i){
   string   name  = GlobalVariableName(i);
   if (PREFIX == StringSubstr(name,0,PREFIX_LEN) ){
      cid = (long) StringSubstr(name,PREFIX_LEN);
      break;
   }
}
Print(cid);
 
William Roeder:

good tips

tnx

Reason: