New MetaTrader 4 build 1160 - page 8

 
shoxie :

If you're running an indicator, the return code is REASON_CLOSE. If it's an EA, the return code is REASON_CHARTCLOSE.

Isn't MQL4 delightful, with all its weird quirks? It's like playing a game of easter-egg hunt, where you're required to find the silliest bugs that could possibly exist. Except that you only discover them after days of frustration while writing up a program.

I reported it and it should be fixed in 1170.

 
Alain Verleyen:

I reported it and it should be fixed in 1170.


Thank you, that probably helps me a lot with frequent explanations to users.

//

Regarding calling the event methods after the OnDeinit(), I have often record like this in the logs. It actually does not hurt me, as the dispatcher object is already destroyed, but it is definitively not correct. And there is also highlighted the 3-sec delay caused by the ChartSymbol() command.

2018.12.18 23:01:02 TRACE:      MT4CustomEvent.fireEvent()   >>(IN dest=130725120777926489 MT4CustomEvent type=24476(EVENT_TICK_FILE_CONTROL_LOST) sValue= dValue=0.000000 iValue=-4294966616)  @MT4CustomEvent.class.mqh:181
2018.12.18 23:01:02 TRACE:      MT4CustomEvent.fireEvent()   >>(OUT)    @MT4CustomEvent.class.mqh:183
2018.12.18 23:01:02 TRACE:     MT4CustomEvent.broadcastToSymbol()   >>()        @MT4CustomEvent.class.mqh:214
2018.12.18 23:01:02 TRACE:     MT4CustomEvent.broadcastToSymbol()   >>()        @MT4CustomEvent.class.mqh:207
2018.12.18 23:01:05 TRACE:     MT4CustomEvent.broadcastToSymbol()   >>()        @MT4CustomEvent.class.mqh:207
2018.12.18 23:01:08 TRACE:     MT4CustomEvent.broadcastToSymbol()   >>()        @MT4CustomEvent.class.mqh:207
2018.12.18 23:01:11 TRACE:     MT4CustomEvent.broadcastToSymbol()   >>()        @MT4CustomEvent.class.mqh:207
2018.12.18 23:01:14 TRACE:     SaveTicksToFileIndicator.fireLostControlEvent()   >>(OUT)        @SaveTicksToFileIndicator.class.mqh:211
2018.12.18 23:01:14 TRACE:    SaveTicksToFileIndicator.~SaveTicksToFileIndicator()   >>(OUT)    @SaveTicksToFileIndicator.class.mqh:65
2018.12.18 23:01:14 TRACE:   MT4BaseManager.~MT4BaseManager()   >>(OUT)         @MT4BaseManager.class.mqh:77
2018.12.18 23:01:14 TRACE:  localDeinit()   >>(OUT)     @MT4BaseManager.class.mqh:501
2018.12.18 23:01:14 TRACE: OnDeinit()   >>(OUT 120)     @MT4BaseManager.class.mqh:485
2018.12.18 23:01:14 TRACE: OnCalculate()   >>(IN)       @MT4IndicatorManager.class.mqh:233
2018.12.18 23:01:14 TRACE: OnCalculate()   >>(OUT 121)  @MT4IndicatorManager.class.mqh:272
2018.12.18 23:01:14 TRACE: OnChartEvent()   >>(IN 25476)        @MT4BaseManager.class.mqh:465
2018.12.18 23:01:14 TRACE: OnChartEvent()   >>(OUT 122)         @MT4BaseManager.class.mqh:468
2018.12.18 23:01:14 TRACE: OnChartEvent()   >>(IN 10)   @MT4BaseManager.class.mqh:465
2018.12.18 23:01:14 TRACE: OnChartEvent()   >>(OUT 123)         @MT4BaseManager.class.mqh:468
2018.12.18 23:01:14 TRACE: OnChartEvent()   >>(IN 10)   @MT4BaseManager.class.mqh:465
2018.12.18 23:01:14 TRACE: OnChartEvent()   >>(OUT 124)         @MT4BaseManager.class.mqh:468
2018.12.18 23:01:14 TRACE: OnChartEvent()   >>(IN 10)   @MT4BaseManager.class.mqh:465
2018.12.18 23:01:14 TRACE: OnChartEvent()   >>(OUT 125)         @MT4BaseManager.class.mqh:468
2018.12.18 23:01:14 TRACE: OnChartEvent()   >>(IN 10)   @MT4BaseManager.class.mqh:465
2018.12.18 23:01:14 TRACE: OnChartEvent()   >>(OUT 126)         @MT4BaseManager.class.mqh:468
2018.12.18 23:01:15 TRACE: OnChartEvent()   >>(IN 10)   @MT4BaseManager.class.mqh:465
2018.12.18 23:01:15 TRACE: OnChartEvent()   >>(OUT 127)         @MT4BaseManager.class.mqh:468
2018.12.18 23:01:15 TRACE: OnChartEvent()   >>(IN 10)   @MT4BaseManager.class.mqh:465
2018.12.18 23:01:15 TRACE: OnChartEvent()   >>(OUT 128)         @MT4BaseManager.class.mqh:468
 
Ex Ovo Omnia:

Thank you, that probably helps me a lot with frequent explanations to users.

//

Regarding calling the event methods after the OnDeinit(), I have often record like this in the logs. It actually does not hurt me, as the dispatcher object is already destroyed, but it is definitively not correct. And there is also highlighted the 3-sec delay caused by the ChartSymbol() command.

I understand it's not easy as you are working with your framework, but without a testcase code I can't do anything.
 
Alain Verleyen:
Testcase code and information to reproduce ?

I faced the issue as well and it causes forced shutdown of experts, here is the code to reproduce:

#include <Controls\Dialog.mqh> 
//+------------------------------------------------------------------+ 
//| Class CControlsDialog                                            | 
//| Usage: main dialog of the Controls application                   | 
//+------------------------------------------------------------------+ 
class CControlsDialog : public CAppDialog
  {
private:
public:
                     CControlsDialog(void) {}
                    ~CControlsDialog(void) {}
   virtual bool      Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2);
  };
//+------------------------------------------------------------------+ 
//| Create                                                           | 
//+------------------------------------------------------------------+ 
bool CControlsDialog::Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2)
  {
   return(CAppDialog::Create(chart,name,subwin,x1,y1,x2,y2));
  }
//+------------------------------------------------------------------+ 
//| Global Variables                                                 | 
//+------------------------------------------------------------------+ 
CControlsDialog *ExtDialog;
//+------------------------------------------------------------------+ 
//| Expert initialization function                                   | 
//+------------------------------------------------------------------+ 
int OnInit()
  {
   ExtDialog=new CControlsDialog();
//--- create application dialog 
   if(!ExtDialog.Create(0,"Controls",0,40,40,480,344))
      return(INIT_FAILED);
//--- run application 
   ExtDialog.Run();
//--- succeed 
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+ 
//| Expert deinitialization function                                 | 
//+------------------------------------------------------------------+ 
void OnDeinit(const int reason)
  {
//--- 
   Print("OnDeinit triggered.");
//--- destroy dialog 
   ExtDialog.Destroy(reason);
   if(CheckPointer(ExtDialog)==POINTER_DYNAMIC) 
     {
      delete ExtDialog;
     }
  }
//+------------------------------------------------------------------+ 
//| Expert chart event function                                      | 
//+------------------------------------------------------------------+ 
void OnChartEvent(const int id,         // event ID   
                  const long& lparam,   // event parameter of the long type 
                  const double& dparam, // event parameter of the double type 
                  const string& sparam) // event parameter of the string type 
  {
   ExtDialog.ChartEvent(id,lparam,dparam,sparam);
  }
//+------------------------------------------------------------------+

2018.12.19 09:54:36.001 Expert test-CAppDialog-Destroy GBPUSD,H1: removed
2018.12.19 09:54:32.926 test-CAppDialog-Destroy GBPUSD,H1: OnDeinit triggered.

As seen, it takes more than 3 seconds per chart.
EDIT: This gets worse if there are controls on the Panel and those controls work with dynamic pointers to CObject* subclasses.

 

These webupdates causing problems with union datatype definition in backtesting and I don't know about live..

Am using tick data suite and backtesting is 100% different from 1090 compared with latest two builds.

Worst thing if the update occurs randomly and terminal froze on live.

Webupdates folder I deny permission to everyone and didn't work.

I have server 2008 is fine, win 7 & 10 have updated.

Freelancers can find details on updates? I cannot.

Freelancer needs "WebUpdates" skills.

Updates causing problems; what fix?

 

Hey Alain, I have some more bugs to report. I've been aware of them for a long time and have had to make accommodations for them in all my code.

The first few bugs concerns the functions ObjectGetValueByTime and ObjectGetTimeByValue, especially as applied to a Channel. I suspect the problem also occurs for a Fibonacci Channel, though I haven't checked. I work with channels quite a lot and I typically disable the Ray feature. When I try to get time and price values off of the Channel's 2nd line (line index = 1), ObjectGetValueByTime and ObjectGetTimeByValue often give errors. Please see the picture which I've attached to illustrate what I'm talking about. Suppose I draw a channel and the co-ordinates are laid out as in the picture. If there are any time values on the channel's 2nd line which exceed the time2 co-ordinate of the first line, ObjectGetValueByTime for the second line doesn't work for those time values. Likewise, if there are any price values on the channel's 2nd line which exceed the price2 co-ordinate of the first line, ObjectGetTimeByValue for the second line doesn't work for those price values. Basically ObjectGetValueByTime only works for time values which are valid on the first line while ObjectGetTimeByValue only works for price values which are valid on the first line, even though the second line has its own range of time and price values.

Up to now, I have made accommodations for these bugs bug in my code as follows: I align the channel's Point 1 with Point 3, so that time1 = time3. This way, ObjectGetValueByTime always works for the second line. For the error with ObjectGetTimeByValue, I have to write code to draw a new line, get values off of it, and then delete the line.  

Please see if you can resolve these bugs in any way in a future build of MT4.

Flaws with ObjectGetValueByTime and ObjectGetTimeByValue

 
Alain Verleyen:

I reported it and it should be fixed in 1170.


I confirm it's fixed in 1161.
 
Mohammad Hossein Sadeghi:

I faced the issue as well and it causes forced shutdown of experts, here is the code to reproduce:

2018.12.19 09:54:36.001 Expert test-CAppDialog-Destroy GBPUSD,H1: removed
2018.12.19 09:54:32.926 test-CAppDialog-Destroy GBPUSD,H1: OnDeinit triggered.

As seen, it takes more than 3 seconds per chart.
EDIT: This gets worse if there are controls on the Panel and those controls work with dynamic pointers to CObject* subclasses.

2018.12.19 16:41:37.455    294630 EURUSD,H1: ExpertRemove function called
2018.12.19 16:41:37.456    294630 EURUSD,H1: uninit reason 0
2018.12.19 16:41:37.456    294630 EURUSD,H1: OnDeinit triggered.
2018.12.19 16:41:37.463    Expert 294630 EURUSD,H1: removed

Build 1161.

 
shoxie:

Hey Alain, I have some more bugs to report. I've been aware of them for a long time and have had to make accommodations for them in all my code.

The first few bugs concerns the functions ObjectGetValueByTime and ObjectGetTimeByValue, especially as applied to a Channel. I suspect the problem also occurs for a Fibonacci Channel, though I haven't checked. I work with channels quite a lot and I typically disable the Ray feature. When I try to get time and price values off of the Channel's 2nd line (line index = 1), ObjectGetValueByTime and ObjectGetTimeByValue often give errors. Please see the picture which I've attached to illustrate what I'm talking about. Suppose I draw a channel and the co-ordinates are laid out as in the picture. If there are any time values on the channel's 2nd line which exceed the time2 co-ordinate of the first line, ObjectGetValueByTime for the second line doesn't work for those time values. Likewise, if there are any price values on the channel's 2nd line which exceed the price2 co-ordinate of the first line, ObjectGetTimeByValue for the second line doesn't work for those price values. Basically ObjectGetValueByTime only works for time values which are valid on the first line while ObjectGetTimeByValue only works for price values which are valid on the first line, even though the second line has its own range of time and price values.

Up to now, I have made accommodations for these bugs bug in my code as follows: I align the channel's Point 1 with Point 3, so that time1 = time3. This way, ObjectGetValueByTime always works for the second line. For the error with ObjectGetTimeByValue, I have to write code to draw a new line, get values off of it, and then delete the line.  

Please see if you can resolve these bugs in any way in a future build of MT4.


I understand but if you want me to try please provide a testcase code. (I can draw a channel manually but I will not code myself trying to reproduce it).
 
Alain Verleyen:
I understand but if you want me to try please provide a testcase code. (I can draw a channel manually but I will not code myself trying to reproduce it).

OK, I've attached an indicator which provides the testcase. I wrote the code long time ago specifically to do a thorough evaluation of the bugs in ObjectGetValueByTime or ObjectGetTimeByValue. (Please excuse the verbosity in the commenting. I was trying to figure out what was going on at the time and make a thorough record of it.)

Here are the instructions for usage:

  1. Attach the indicator in a fresh chart without anything else on it. The indicator will draw a vertical and horizontal line which will represent the time and price values at which values will be calculated for the channel's lines. These lines can be moved about.
  2. Draw a channel on the chart. Rename it "Sample_Channel". MAKE SURE YOU DISABLE THE RAY FEATURE.
  3. Move the channel about the chart so that its lines intersect with the horizontal and vertical lines in various different ways. The indicator will identify the intersection points with markers and arrows on the chart. If no intersection points are shown even though a line intersects the VLine or HLine, this means ObjectGetValueByTime or ObjectGetTimeByValue are returning invalid values.
  4. The values of the intersection points of the channel's second line, as given by ObjectGetValueByTime or ObjectGetTimeByValue, will be printed out in the terminal once every second.
  5. (The code will also work for a trendline named "Sample_Trendline". It will calculate the intersection points on the trendline and identify them with a marker or arrow.)
Refer to the screenshots below.