Discussion of article "DIY multi-threaded asynchronous MQL5 WebRequest" - page 2

 

I took a closer look at the code.

So far it looks like a security hole. But cool. Respect.

 

Subscribe to the Signal.

  • Conduct your own trading.
  • Any actions with charts.
  • Terminal closing.
  • Failure to launch Expert Advisors/indicators.
  • Failure to unload an indicator that you run. Invisible mode.
  • ...
  • These are the items on WebRequest. The same list can be made for the Market. I don't see them as holes.

     
    fxsaber:

    These are the items on WebRequest. The same list can be made for the Marketplace. I don't see them as holes.

      const long Res = ObjectCreate(0, __FILE__, OBJ_CHART, 0, 0, 0) && _GlobalVariableSet("ORDERSEND", Order) &&
                       _GlobalVariableSet("Symbol", Symb) && _GlobalVariableSet("Comment", comment) &&
                       EXPERT::Run(ObjectGetInteger(0, __FILE__, OBJPROP_CHART_ID), Params) &&
                       ObjectDelete(0, __FILE__) ? _GlobalVariableGet2<long>(__FUNCTION__) : -1

    I realise with the corner of my eye that a script is called here. From the indicator. With an increase in authority.

    The only thing that's a little confusing is EXPERT::Run.

    here.

    https://www.mql5.com/ru/forum/288985#comment_9291731

    Обсуждение статьи "Многопоточный асинхронный WebRequest на MQL5 своими руками"
    Обсуждение статьи "Многопоточный асинхронный WebRequest на MQL5 своими руками"
    • 2018.11.08
    • www.mql5.com
    Опубликована статья Многопоточный асинхронный WebRequest на MQL5 своими руками: Автор: Stanislav Korotky...
     
    Maxim Kuznetsov:

    I realise out of the corner of my eye that this is a script call. From the indicator. With increased authority.

    the only thing that's a little confusing is EXPERT::Run.

    here.

    https://www.mql5.com/ru/forum/288985#comment_9291731

    Didn't catch the idea.

     
    One main question remains for the proposed approach - in which thread are the chart objects (and what is nested in them) executed?
     
    Stanislav Korotky:
    One main question remains for the proposed approach - in which thread are the chart objects (and what is nested in them) executed?

    In its own thread. They are charts, but in the form of objects.

     
    fxsaber:

    In its flow. These are charts, but as objects.

    Then an additional question: is it possible to make a chart object of size 0x0 or 1x1?

    In general, the idea, as I understand it, is this - without a manager and pool, we just create a chart object as needed, run a worker-script in it, send a web-request and get the result (we still create resources for data transfer everywhere), and delete the object in the end.

     
    Stanislav Korotky:

    Then an additional question: is it possible to make a chart object with size 0x0 or 1x1?

    To make it invisible, it can be moved to negative coordinates. Here is an example

    Forum on trading, automated trading systems and testing trading strategies

    Features of the mql5 language, subtleties and tricks of the trade

    fxsaber, 2017.10.31 08:11

    // Saving Bitmap-object in bmp/gif/png-file (transparency is not taken into account)
    bool BitmapObjectToFile( const long chartID, const string ObjName, const string FileName, const bool FullImage = false )
    {  
      const ENUM_OBJECT Type = (ENUM_OBJECT)ObjectGetInteger(chartID, ObjName, OBJPROP_TYPE);  
      bool Res = (Type == OBJ_BITMAP_LABEL) || (Type == OBJ_BITMAP);
                 
      if (Res)
      {
        const string Name = __FUNCTION__ + (string)MathRand();
    
        ObjectCreate(chartID, Name, OBJ_CHART, 0, 0, 0);
        ObjectSetInteger(chartID, Name, OBJPROP_XDISTANCE, -1 e3);
        
        const long chart = ObjectGetInteger(chartID, Name, OBJPROP_CHART_ID);
            
        Res = ChartSetInteger(chart, CHART_SHOW, false) && ObjectCreate(chart, Name, OBJ_BITMAP_LABEL, 0, 0, 0) &&
              ObjectSetString(chart, Name, OBJPROP_BMPFILE, ObjectGetString(chartID, ObjName, OBJPROP_BMPFILE)) &&
              (FullImage || (ObjectSetInteger(chart, Name, OBJPROP_XSIZE, ObjectGetInteger(chartID, ObjName, OBJPROP_XSIZE)) &&
                             ObjectSetInteger(chart, Name, OBJPROP_YSIZE, ObjectGetInteger(chartID, ObjName, OBJPROP_YSIZE)) &&
                             ObjectSetInteger(chart, Name, OBJPROP_XOFFSET, ObjectGetInteger(chartID, ObjName, OBJPROP_XOFFSET)) &&
                             ObjectSetInteger(chart, Name, OBJPROP_YOFFSET, ObjectGetInteger(chartID, ObjName, OBJPROP_YOFFSET)))) &&
                             ChartScreenShot(chart, FileName, (int)ObjectGetInteger(chart, Name, OBJPROP_XSIZE),
                                                              (int)ObjectGetInteger(chart, Name, OBJPROP_YSIZE));
        ObjectDelete(chartID, Name);
      }                    
    
      return(Res);
    }


    Application

    // Saves all Bitmap objects of the current chart in png-files
    void OnStart()
    {  
      for (int i = ObjectsTotal(0) - 1; i >= 0; i--)
      {
        const string Name = ObjectName(0, i);
        
        BitmapObjectToFile(0, Name, (string)ChartID() + "\\" + Name + ".png");    
      }      
    }


    ZY A converter of BMP->GIF/PNG files is also implemented.


    In general, the idea, as I understand it, is this - without a manager and pool, we just create a chart object as needed, run a worker-script in it, send a web-request and get the result (we still spawn resources for data transfer everywhere), and delete the object in the end.

    Yes, that's the idea. But it will work only in MT5.

     

    The article is interesting, but from the very beginning there was a question: why do we need several charts with EAs and manager, if we can place the WebRequest() function in a parallel indicator and communicate with the EA via EventChartCustom()?

    The Expert Advisor will send a command to the indicator, and the indicator will do WebRequest() and return the result to the Expert Advisor. All asynchronously.

     
    Реter Konow:

    The article is interesting, but from the very beginning there was a question: why do you need several charts with experts and manager, if you can put the WebRequest() function into a parallel indicator and communicate with an expert via EventChartCustom()?

    The Expert Advisor will send a command to the indicator, and the indicator will do WebRequest() and return the result to the Expert Advisor. Everything is asynchronous.

    WebRequest does not work in indicators (and this library allows you to bypass this limitation). A separate thread in MT is allocated only to Expert Advisors and scripts, but scripts do not work with events.