Download MetaTrader 5

Chart Operations work on startup only

To add comments, please log in or register
webbed
12
webbed  

Hi, I've ‌got simple code to take screen shots of all my open charts:

int OnInit()
  {
   takeScreenShot();
   return(INIT_SUCCEEDED);
  }

void takeScreenShot()
{
   string filename = "";
   long thisChartID = ChartID();
   long currChart=ChartFirst();
   int i=0,limit=100;

   while(i<limit)
   {
      filename = ChartSymbol(currChart) + " " + ChartPeriod(currChart) + ".gif";
      Print("chart printed: " + ChartScreenShot(currChart,filename,1500,600,ALIGN_RIGHT) + " symbol: " + ChartSymbol(currChart) + " period: " + ChartPeriod(currChart));
      currChart=ChartNext(currChart);
      if(currChart<0) break;
      i++;
   }  
}

It works perfectly when the code is in a script. However, when it is executed in an EA, it only works the FIRST time. All subsequent runs will return 0 for ChartPeriod(), and blank for ChartSymbol();

‌I need to restart my MT4 application in order for it to work again. Here is the output from 2 runs of the EA:

‌‌I've uninstalled MT4, and rebooted my machine multiple times. This is happening on two separate computers, so I don't think it is a code issue. Any ideas? I'm stumped! I'm on OANDA practice account.

Alain Verleyen
Moderator
33504
Alain Verleyen  
Which build are you using ?
Alain Verleyen
Moderator
33504
Alain Verleyen  
Alain Verleyen:
Which build are you using ?

Anyway, that seems a MT4 bug (tested on build 1031).

I got a "ghost" chart :

2017.03.03 09:47:24.899    171552 AUDUSD,M5: chart printed: 1 symbol: AUDUSD period: 5 ID: 131074241499052364 Current: 131074241499052364
2017.03.03 09:47:24.970    171552 AUDUSD,M5: chart printed: 1 symbol: USDCHF period: 240 ID: 131074241499326034 Current: 131074241499052364
2017.03.03 09:47:25.037    171552 AUDUSD,M5: chart printed: 1 symbol: GBPUSD period: 240 ID: 131074241499646253 Current: 131074241499052364
2017.03.03 09:47:25.090    171552 AUDUSD,M5: chart printed: 1 symbol: USDJPY period: 240 ID: 131074241501402788 Current: 131074241499052364
2017.03.03 09:47:25.090    171552 AUDUSD,M5: chart printed: 1 symbol:  period: 0 ID: 131329162160897678 Current: 131074241499052364

I have only 4 charts open. This MT4 instance was running since some days. After a restart of MT4 all ‌is ok.

EDIT: I can't reproduce the problem, so maybe not easy to fix. Please report it to ServiceDesk.‌

webbed
12
webbed  

I‌'m on build 1045.‌‌

Thanks Alain Verleyen. It's a weird error. I do get around it by restarting my MT4 everytime I do something. Not a major issue. Just annoying.

Slava
Moderator
7006
Slava  
Build 1052 helps you
To add comments, please log in or register