What is meant with ID of ChartFirst() by this huge numbers much bigger than CHARTS_MAX = 100?
Ask MQ
ChartFirst returns the ChartID from the first chart
so in order to use it right:
long Ch01 = ChartFirst(), /* the ChartID() from the first chart */ Current = ChartID(); //the ChartID() from the Current Chart long ChNx = ChartNext(Ch01); //the ChartID() from the Second Chart
Hi I just started in debug mode in a script just this:
and get:
I expect s.th. like 0, 3, -1 it is the last Chart?? What is meant with ID of ChartFirst() by this huge numbers much bigger than CHARTS_MAX = 100?
Can I (my EA) find out on which chart it is running with the idea that the first chart should have either 0 or 1 and the next chart just 1 more.
Gooly
PS: I I run this script
directly on the first chart with no other chart I get ( ChNx != -1 ??)
long chartID=ChartFirst(); for(int i=0; i<128; i++) // I didn't test 128 charts, but read that MT4 allows 128 opened charts { chartID=ChartNext(chartID); // do what you need for opened charts }In other words:
The ChartID() seems to be some large number,
The ChartID()'s aren't in any specific order (we can change the order of tabs manually),
The code is not counting the charts,
The code is only returning the ChartID() for every opened chart.
ChartNext() etc returns each chartid in your collection of charts.
You need to figure out how to use the chartids to meet the needs of your EA.
The EA's chart will just be ChartID() and this code creates an array of charts on your screen.
void chartsupdate(){ long charts[],thisid=0; int ct=0; do{ thisid=ChartNext(thisid); if(thisid==-1)break; //reached the end of chart collection //if(thisid==ChartID())continue; // exclude the host chart ArrayResize(charts,ct+1); charts[ct]=thisid; ct++; } while(ct<100); string txt=""; for(int i=0;i<ArraySize(charts);i++){ txt=StringConcatenate(txt,charts[i]," sym ",ChartSymbol(charts[i]),"\n"); } Comment (txt); /* returns (2 charts on my terminal) 133608982605570143 sym NZDCHF.r 133610036888496035 sym ETHEREUM */ }
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi I just started in debug mode in a script just this:
and get:
I expect s.th. like 0, 3, -1 it is the last Chart?? What is meant with ID of ChartFirst() by this huge numbers much bigger than CHARTS_MAX = 100?
Can I (my EA) find out on which chart it is running with the idea that the first chart should have either 0 or 1 and the next chart just 1 more.
Gooly
PS: I I run this script
directly on the first chart with no other chart I get ( ChNx != -1 ??)