ChartOpen() problem

 

hi all,

I am closing all open charts and then opening a defined set of charts afterwards.

void OnStart()
{
 long nextChart = ChartNext(ChartID());

 //closes all open charts
 while(nextChart > 0 || ChartFirst() != ChartID())
 {
  nextChart = ChartNext(ChartID());
  if(nextChart > 0)ChartClose(nextChart);
  if(ChartFirst() != ChartID())ChartClose(ChartFirst());
  Sleep(200);
 }
  //close last chart
  ChartClose(ChartID());
  ChartOpen("XAUUSD",PERIOD_M5);
  ChartOpen("EURUSD",PERIOD_M5);
  ChartOpen("GBPUSD",PERIOD_M5);
  ChartOpen("USDJPY",PERIOD_M5);
}

This code works fine.

string symbol[4] = {"XAUUSD","EURUSD","GBPUSD","USDJPY"};

void OnStart()
{
 long nextChart = ChartNext(ChartID());

 //closes all open charts
 while(nextChart > 0 || ChartFirst() != ChartID())
 {
  nextChart = ChartNext(ChartID());
  if(nextChart > 0)ChartClose(nextChart);
  if(ChartFirst() != ChartID())ChartClose(ChartFirst());
  Sleep(200);
 }
  //close last chart
  ChartClose(ChartID());

Sleep(200);
long chart_id;
 for(int i=0;i<ArraySize(symbol);i++)
 {
  //open charts and apply templates
  chart_id = ChartOpen(symbol[i],PERIOD_M5);
  ChartSetInteger(chart_id,CHART_SHIFT,True);
  ChartSetInteger(chart_id,CHART_AUTOSCROLL,True);
  Sleep(200);
 }
}

This code does not open any charts.

Any ideas please?

 

This is the output if I put in print statement to print ChartID and GetLastError()


 
sd59:

hi all,

I am closing all open charts and then opening a defined set of charts afterwards.

This code works fine.

This code does not open any charts.

Any ideas please?

The internal error is here:

  ChartSetInteger(chart_id,CHART_SHIFT,True);
  ChartSetInteger(chart_id,CHART_AUTOSCROLL,True);

MQL5 does not accept True syntax, only true (lowercase).

  ChartSetInteger(chart_id,CHART_SHIFT,true);
  ChartSetInteger(chart_id,CHART_AUTOSCROLL,true);
 
Roberto Jacobs #:

The internal error is here:

MQL5 does not accept True syntax, only true (lowercase).

sorry for late reply on this..

my code is MQL4 and even if I remove those two lines of code the result is the same 'internal error' and no charts are opened.

Reason: