Duplicate ChartID in MT4 noticed !!

 

Dear MetaQuotes-Team!

I noticed duplicate ChartIDs within one MT4-Terminals for a while ... thought you would correct this issue - but you didn't.

Could you please give a clear answer why duplicate ChartIDs can exist (which does not make sense to me - should be unique, or not?).

Thank you very much in advance!!

Mark

Dateien:
 
M111 :
...
Sagen Sie uns bitte, wie wir das reproduzieren sollen.
 
Alain Verleyen:
Sagen Sie uns bitte, wie wir das reproduzieren sollen.

Hi Alain!


Thank you very much for your investigation - i know you are one of the well educated forum-members ...
I will answer in english - maybe another "brilliant brain" will follow or join this topic.

I've installed several MT4-Instances (all are updated regularly in time) - only a few of them show
this behavior.

Attached you will find two indicators which
A.) list all ChartID()'s of used MT4-Terminal
B.) shows ChartID() of actual Chart

- and a new, different hardcopy, where the "error" is shown.

Interesting:
duplicated ChartIDs should be orange-colored - but they aren't. Hmmm ... something is strange.
Any idea ? Did i made a mistake during programming? (I'm not a native C/C++/MQL4-Programmer)

Just open a new chart and attach the Listing-indicator which will detect all existing charts automatically.


Thanks a lot again!
Mark


Dateien:
 

The problem seems to be here:

DoubleToString(ChartIDs[gg][00],0)

if a long value at the size of the chart ID is converted into a double the double value is only close to the long value:

long x = ChartNext(...);

long y = (long) ( (double) x);

and now you'll see:

x != y
 
Carl Schreiber:

The problem seems to be here:

if a long value at the size of the chart ID is converted into a double the double value is only close to the long value:

long x = ChartNext(...);

long y = (long) ( (double) x);

and now you'll see:

Carl, you are sooo right!

Solution is so easy !

Normaly i tend to avoid every compiler-warning during programming.

Due to missing function - LongToString- i used -DoubleToString-,
which is obviously wrong - see picture: "Duplicate ChartIDs _ 05 - final".

--> (string) ChartIDs[gg][00]    .... is perfect for display and generates no warning.


Carl and Alain ... thank you very much - i appreciate your help!
Mark

================================================

--> issue is resolved - issue is no issue - no duplicate chartid's within one MT4-Terminal! Great!

 

Gerne,

ich hatte das Problem, als ich die ChartID den globalen Variablen des Terminals zuweisen wollte, um zu verhindern, das ein EA ein zweites Mal, auf demselben Symbol gestartet wurde. Aber da das double  Werte sind funktionierte es nicht. :(

Viel Erfolg

Calli

PS in Zukunft können wir Deutsch reden, ok?

:)

 
Carl Schreiber:

Gerne,

ich hatte das Problem, als ich die ChartID den globalen Variablen des Terminals zuweisen wollte, um zu verhindern, das ein EA ein zweites Mal, auf demselben Symbol gestartet wurde. Aber da das double  Werte sind funktionierte es nicht. :(

Viel Erfolg

Calli

PS in Zukunft können wir Deutsch reden, ok?

:)

Manchmal sieht man den Wald vor lauter Bäumen nicht ... Danke nochmals !!
 
M111 :

Carl, you are sooo right!

Solution is so easy !

Normaly i tend to avoid every compiler-warning during programming.

Due to missing function - LongToString- i used -DoubleToString-,
which is obviously wrong - see picture: "Duplicate ChartIDs _ 05 - final".

--> (string) ChartIDs[gg][00]    .... is perfect for display and generates no warning.


Carl and Alain ... thank you very much - i appreciate your help!
Mark

================================================

--> issue is resolved - issue is no issue - no duplicate chartid's within one MT4-Terminal! Great!

Wenn Sie eine Funktion verwenden möchten, die IntegerToString () ist, kann der Parameter long as dauern. Grundsätzlich ist es dasselbe wie (string), aber es gibt einige zusätzliche Möglichkeiten.

 
Carl Schreiber:

Gerne,

ich hatte das Problem, als ich die ChartID den globalen Variablen des Terminals zuweisen wollte, um zu verhindern, das ein EA ein zweites Mal, auf demselben Symbol gestartet wurde. Aber da das double  Werte sind funktionierte es nicht. :(

Viel Erfolg

Calli

PS in Zukunft können wir Deutsch reden, ok?

:)

union DBL_LONG
 {
  double dbl;
  long   lng;
 } value_8bytes;

void OnStart()
 {
  long chartID        = ChartID();
  const string gv     = "TEST_331473";
  value_8bytes.lng    = chartID;
  GlobalVariableSet(gv,value_8bytes.dbl);
  value_8bytes.dbl    = GlobalVariableGet(gv);
  long restoreChartID = value_8bytes.lng;
  
  printf("Initial ChartID: %lli Restored Chart ID: %lli",chartID,restoreChartID);
 }
Initial ChartID: 132248638204313830 Restored Chart ID: 132248638204313830
Grund der Beschwerde: