Download MetaTrader 5

New MetaTrader 4 Platform build 1045 - page 4

To add comments, please log in or register
Max Enrik
994
Max Enrik  
whroeder1:
What build? There are no mind readers here.

I think thread name is enough.

build 1045 

khryniewiecki
23
khryniewiecki  

MetaTrader 4 Terminal, Build 1045 

The Code:

 int OnInit() { 

  Print("start");

  return(INIT_SUCCEEDED);

}


void OnDeinit(const int reason) {

  Print("end");  // Does not print "end" to the log when closing the chart window

}

 

 

The Log:

2017.02.05 17:18:14.231 Expert test EURUSD+,H1: removed

2017.02.05 17:18:14.215 test EURUSD+,H1: uninit reason 4

2017.02.05 17:18:12.287 test EURUSD+,H1: initialized

2017.02.05 17:18:12.287 test EURUSD+,H1: start

2017.02.05 17:18:11.006 Expert G1\test EURUSD+,H1: loaded successfully

 

 

QUESTION

Where is my "end"? 

 

Instruction:

1. Run the expert. 

2. Close the chart window with the expert (do not remove the expert from the chart because in this case "end" is printed - at least sometimes). 

 

Tip 

Destructors for automatic objects are not called as well.  

 

 


JC
1498
JC  
Marcin Madrzak:

I have a problem with my EA in the latest build - 1045. When switching TFs or Symbols EA is not initialized. 

I am only personally seeing a problem under the following circumstances:

  • An EA does ChartSetSymbolPeriod() on its own chart
  • There is other code, after ChartSetSymbolPeriod(), before the EA exits from OnTimer()/OnTick()

I appear to be able to fix this for my own code by making sure that ChartSetSymbolPeriod() is the last thing which the EA does before returning from OnTimer()/OnTick()

However, I'm very suspicious that there is some sort of race condition in the new build of MT4. It looks very plausible that there is a problem which, for me, only manifests itself in an EA changing its own symbol/timeframe, but on other computers is capable of applying to things like the manual changing of symbol/tf which you describe.

In short: I can definitely confirm some kind of bug, which goes away if I downgrade to v1031.

JC
1498
JC  
JC:

In short: I can definitely confirm some kind of bug, which goes away if I downgrade to v1031.

... Now that I go back and check, the problem also applies to the interim testing builds 1032 and 1033. The last unaffected, bug-free build is the release v1031.
Ex Ovo Omnia
3264
Ex Ovo Omnia  
JC:

I am only personally seeing a problem under the following circumstances:

  • An EA does ChartSetSymbolPeriod() on its own chart
  • There is other code, after ChartSetSymbolPeriod(), before the EA exits from OnTimer()/OnTick()

I appear to be able to fix this for my own code by making sure that ChartSetSymbolPeriod() is the last thing which the EA does before returning from OnTimer()/OnTick()

However, I'm very suspicious that there is some sort of race condition in the new build of MT4. It looks very plausible that there is a problem which, for me, only manifests itself in an EA changing its own symbol/timeframe, but on other computers is capable of applying to things like the manual changing of symbol/tf which you describe.

In short: I can definitely confirm some kind of bug, which goes away if I downgrade to v1031.

If you mean it, then this bug with ChartSetSymbolPeriod was there some time ago. The worst thing was, that after init/deinit the script continued with the command immediately following the ChartSetSymbolPeriod (which usually ended in crash).

JC
1498
JC  
Ovo Cz:

If you mean it, then this bug with ChartSetSymbolPeriod was there some time ago. The worst thing was, that after init/deinit the script continued with the command immediately following the ChartSetSymbolPeriod (which usually ended in crash).

Never previously had a problem with ChartSetSymbolPeriod(). I only see a problem in builds 1032 onwards, not in the last release v1031.

The behaviour I am seeing is as follows:

  • ChartSetSymbolPeriod() called; returns true
  • EA continues through to end of OnTimer(), executing other clean-up code
  • OnDeInit() is called successfully and correctly
  • But EA is never reloaded

This seems related to the other reports regarding manual changes of tf/symbol, and screams "race condition" at me.

Max Enrik
994
Max Enrik  

I deleted this part of code from my Trade Panel EA. It works perfect.
But I need to use it.

for( i = OrdersHistoryTotal() - 1; i >= 0; i-- )
  {
   bool order_selected=OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
   if(order_selected==1)
     {
      ObjectsDeleteAll(0,"#"+IntegerToString(OrderTicket()));
      ObjectsDeleteAll(0,prefix+" #"+IntegerToString(OrderTicket()));
     }
  }

Any help, would be better.

Thanks. 

JC
1498
JC  
Max Enrik:

I deleted this part of code from my Trade Panel EA. [...]

(I don't want to sound like a broken record, but I'd currently place a small bet that the issue is not specifically to do with chart objects, but is instead that the time spent cleaning up the chart objects creates a timing issue vs other actions to do with reloading the EA.)
JC
1498
JC  
JC:
(I don't want to sound like a broken record, but I'd currently place a small bet that the issue is not specifically to do with chart objects, but is instead that the time spent cleaning up the chart objects creates a timing issue vs other actions to do with reloading the EA.)

I now have a pretty minimal test case.

If I load the following EA onto a chart...

#property strict

void OnTick() {}

void OnDeinit(const int reason)
{
   Sleep(1);
} 

 ... then, when I manually change the timeframe or symbol of the chart, the EA is unloaded but not reloaded.

Works fine in build 1031. 

Max Enrik
994
Max Enrik  
JC:

I now have a pretty minimal test case.

If I load the following EA onto a chart...

#property strict

void OnTick() {}

void OnDeinit(const int reason)
{
   Sleep(1);
} 

 ... then, when I manually change the timeframe or symbol of the chart, the EA is unloaded but not reloaded.

Works fine in build 1031. 

I do not use Sleep(), but I use EventSetTimer(), EventKillTimer(), so I removed them ( for just test ) but EA still does not reloaded when I try to change timeframes.
123456789101112
To add comments, please log in or register