Download MetaTrader 5
To add comments, please log in or register
MQL5 library has more than 1500 apps already. Contribute your own one!
Blackriver67
119
Blackriver67 2014.09.02 01:53 

Hi,

I was playing around with Chart Operations because I want create a script which applies a certain template to all open charts...

I use this script below as a first test to get info from all open charts but the ChartSymbol() and ChartPeriod() functions only work for the current chart. if I use them with a specific Chart ID I get an access violation 0x0840E000 in the script.

Can anyone help me what is wrong, please

void OnStart()
  {

   long chartID;
   chartID=ChartFirst();
   
   while (chartID!=-1)
   {
      Print ("Symbol = ", ChartSymbol(chartID)," Period = ",ChartPeriod(chartID)," ID = ",chartID);
      chartID=ChartNext(chartID);
   }   
   
  }
qjol
3243
qjol 2014.09.02 03:37  
access violation has noting to do with ChartSymbol() and/or ChartPeriod() it's been caused by a dll you importing
Blackriver67
119
Blackriver67 2014.09.02 08:06  
qjol:
access violation has noting to do with ChartSymbol() and/or ChartPeriod() it's been caused by a dll you importing

I don't know.

I just know that MT4 brings in the Terminal under Experts the error message "Access violation read to 0x0840E000 in..." and then comes the name of my script file... Apart from that the script does only consit of what I posted above. So I do not import any dll.

But as mentioned If I just use this syntax ChartSymbol() or ChartPeriod() which refers to the activated (current) chart it works. But when I use these functions with the reverence to a chart_id MT4 brings the above error message...?!?!?

Do I have to import a certain dll that these functions work in MT4 (I use build 670)?

qjol
3243
qjol 2014.09.02 11:42  

try to open a clean new script and paste the code above and see if there is an access violation

 

Blackriver67:

 

Do I have to import a certain dll that these functions work in MT4 (I use build 670)?



no, i use the same version, no problem at all
Blackriver67
119
Blackriver67 2014.09.02 15:27  
qjol:

try to open a clean new script and paste the code above and see if there is an access violation

 


no, i use the same version, no problem at all

 


Strange I do not get that stuff working. Not even the example of the ChartNext() documentation...
 long currChart,prevChart=ChartFirst();
   int i=0,limit=100;
   Print("ChartFirst =",ChartSymbol(prevChart)," ID =",prevChart);
   while(i<limit)// We have certainly not more than 100 open charts
     {
      currChart=ChartNext(prevChart); // Get the new chart ID by using the previous chart ID
      if(currChart<0) break;          // Have reached the end of the chart list
      Print(i,ChartSymbol(currChart)," ID =",currChart);
      prevChart=currChart;// let's save the current chart ID for the ChartNext()
      i++;// Do not forget to increase the counter
     }
/
To add comments, please log in or register