Discussion of article "Other classes in DoEasy library (Part 70): Expanding functionality and auto updating the chart object collection"

 

New article Other classes in DoEasy library (Part 70): Expanding functionality and auto updating the chart object collection has been published:

In this article, I will expand the functionality of chart objects and arrange navigation through charts, creation of screenshots, as well as saving and applying templates to charts. Also, I will implement auto update of the collection of chart objects, their windows and indicators within them.

Now it is time to test creating screenshots of the current chart. Each button click creates a chart screenshot of a certain size. First click — 800x600, second — 750x562, third — the current chart size:


After creating three screenshots in different resolutions (accompanied by the appropriate journal entries),

CChartObj::ScreenShot800x600: Screenshot created: DoEasy\ScreenShots\TestDoEasyPart70_EURUSD_H1_2021.04.13_14.02.25.png (800 x 600)
CChartObj::ScreenShot750x562: Screenshot created: DoEasy\ScreenShots\TestDoEasyPart70_EURUSD_H1_2021.04.13_14.02.28.png (750 x 562)
CChartObj::ScreenShotWndSize: Screenshot created: DoEasy\ScreenShots\TestDoEasyPart70_EURUSD_H1_2021.04.13_14.02.29.png (726 x 321)

we also viewed the contents of the folder these screenshots are saved to.
Before creating the screenshots, I hovered the cursor over different areas of two windows of the current chart, and the chart comment displays the time, price and index of the subwindow, as well as the cursor X/Y coordinates in pixels. The cursor Y coordinate has two values. The first value displays the Y coordinate of the initial coordinates of the symbol main window. The second value displayed (in brackets) shows the Y coordinate relative to the upper border of the window the cursor is located in.

Author: Artyom Trishkin

 

Limit Order, using the DeletePending button, gives many identical OnChartEvent events, but there should be different ones, right?

Or via Bulk Operations Delete Limit Orders also gives many identical events.

If you close manually, the events are sequential.


2023.03.07 14:58:31.385 TestDoEasy131 (GBPUSD.c,H1)     - Pending order removed: 2023.03.07 14:57:59.055 -
2023.03.07 14:58:31.385 TestDoEasy131 (GBPUSD.c,H1)     GBPUSD.c Deleted 0.10 Pending order Buy Limit #89090285  at price 1.19636, sl 1.19486, tp 1.19786, Magic number 4718715 (123), G1: 8, G2: 4
2023.03.07 14:58:31.386 TestDoEasy131 (GBPUSD.c,H1)     - Pending order removed: 2023.03.07 14:57:58.395 -
2023.03.07 14:58:31.386 TestDoEasy131 (GBPUSD.c,H1)     GBPUSD.c Deleted 0.10 Pending order Buy Limit #89090282  at price 1.19640, sl 1.19490, tp 1.19790, Magic number 10223739 (123), G1: 12, G2: 9
2023.03.07 14:58:31.386 TestDoEasy131 (GBPUSD.c,H1)     - Pending order removed: 2023.03.07 14:58:00.613 -
2023.03.07 14:58:31.386 TestDoEasy131 (GBPUSD.c,H1)     GBPUSD.c Deleted 0.10 Pending order Buy Limit #89090287  at price 1.19636, sl 1.19486, tp 1.19786, Magic number 6357115 (123), G1: 1, G2: 6
2023.03.07 14:58:31.386 TestDoEasy131 (GBPUSD.c,H1)     - Pending order removed: 2023.03.07 14:57:59.669 -
2023.03.07 14:58:31.386 TestDoEasy131 (GBPUSD.c,H1)     GBPUSD.c Deleted 0.10 Pending order Buy Limit #89090286  at price 1.19636, sl 1.19486, tp 1.19786, Magic number 393339 (123), G1: 6
2023.03.07 14:58:31.392 TestDoEasy131 (GBPUSD.c,H1)     MAGIC = %d10223739
2023.03.07 14:58:31.392 TestDoEasy131 (GBPUSD.c,H1)     2023.03.07 14:58:30
2023.03.07 14:58:31.392 TestDoEasy131 (GBPUSD.c,H1)     OnChartEvent: Pending order removed
2023.03.07 14:58:31.394 TestDoEasy131 (GBPUSD.c,H1)     MAGIC = %d10223739
2023.03.07 14:58:31.394 TestDoEasy131 (GBPUSD.c,H1)     2023.03.07 14:58:30
2023.03.07 14:58:31.394 TestDoEasy131 (GBPUSD.c,H1)     OnChartEvent: Pending order removed
2023.03.07 14:58:31.395 TestDoEasy131 (GBPUSD.c,H1)     MAGIC = %d10223739
2023.03.07 14:58:31.395 TestDoEasy131 (GBPUSD.c,H1)     2023.03.07 14:58:30
2023.03.07 14:58:31.395 TestDoEasy131 (GBPUSD.c,H1)     OnChartEvent: Pending order removed
2023.03.07 14:58:31.397 TestDoEasy131 (GBPUSD.c,H1)     MAGIC = %d10223739
2023.03.07 14:58:31.397 TestDoEasy131 (GBPUSD.c,H1)     2023.03.07 14:58:30
2023.03.07 14:58:31.397 TestDoEasy131 (GBPUSD.c,H1)     OnChartEvent: Pending order removed
 
BillionerClub OnChartEvent events, but there should be different ones.

Or via Bulk Operations Delete Limit Orders gives many identical events

If you close manually, the events are sequential.

I don't understand what you mean...
 
Artyom Trishkin OnChartEvent.
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {


//--- If working in the tester, exit
//if(MQLInfoInteger(MQL_TESTER))
// return;
   int idx=id-CHARTEVENT_CUSTOM;
//--- Extract from lparam (1) the milliseconds of the event time, (2) the cause, (3) the source of the event, and (4) set the exact time of the event
   ushort msc=engine.EventMSC(lparam);
   ushort reason=engine.EventReason(lparam);   ushort source=engine.EventSource(lparam);
   long time=::TimeCurrent()*1000+msc;
//--- Processing of trade events
   if(idx>TRADE_EVENT_NO_EVENT && idx<TRADE_EVENTS_NEXT_CODE)
     {
      //--- Get the list of all trade events
      CArrayObj *list=engine.GetListAllOrdersEvents();
      if(list==NULL)
         return;
      //--- get the event index offset relative to the end of the list
      //--- in the tester the offset is passed by the lparam parameter to the event handler
      //--- not in the tester - each event is sent one at a time and handled in OnChartEvent()
      int shift=(engine.IsTester() ? (int)lparam : 0);
      CEvent *event=list.At(list.Total()-1-shift);

This is how I corrected it, it seems to work.


      int shift=(engine.IsTester() ? (int)lparam : 0);
      static int NEvents =list.Total()-1-shift;
      CEvent *event=list.At(NEvents);
      NEvents++;
 
BillionerClub OnChartEvent occur

This is how I fixed it, it seems to work.


Did you mean that the library sends wrong events to the event handler?
 
Artyom Trishkin #:
Did you mean that the library sends the wrong events to the event handler?

Yes, that's what I meant. I think I fixed it, but I'm not sure about the solution, as I don't really understand where the disadvantages would be.


      int shift=(engine.IsTester() ? (int)lparam : 0);
      static int NEvents =list.Total()-1-shift;
      CEvent *event=list.At(NEvents);
      NEvents++;
      if(event==NULL)
      {
      event=list.At(list.Total()-1-shift);
      if(event==NULL)return;
      }
 
BillionerClub #:

Yeah. That's what I meant. I kind of corrected it, but I'm not sure of the solution as I don't really understand where the downsides would be.


Thanks, I'll take a look