Questions from Beginners MQL5 MT5 MetaTrader 5 - page 317

 
artmedia70:
//+------------------------------------------------------------------+
//|                                                    trendyxV1.mq5 |
//+------------------------------------------------------------------+
#include <Canvas\Canvas.mqh>
CCanvas LomLine;
int KoorX[4]={100,200,350,480};
int KoorY[4]={100,150,380,150};
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   LomLine.Destroy();
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   LomLine.CreateBitmapLabel("trendyx",0,0,800,800,COLOR_FORMAT_ARGB_RAW);
   LomLine.PolylineAA(KoorX,KoorY,ColorToARGB(clrRed, 155),STYLE_SOLID);
   LomLine.Update();

  }
//+------------------------------------------------------------------+

,.

 
pako:

,.

 
EA has stopped opening positions because "invalid integer number as parameter 9 for 'OrderSend' function". Can someone explain what this is? Presumably it was due to an update of the MT4 terminal.
 
Katerina:
EA has stopped opening positions because "invalid integer number as parameter 9 for 'OrderSend' function". Can someone explain what this is? Presumably it's because of MT4 terminal update.
Please attach the code where the"OrderSend" function is called. Supposedly the magic number is not set correctly.
 
Ah, well, I've already fixed it. Thank you for your feedback.
 
I wonder if you can add an animation to the chart in MQl5, like a guy who is pounding on the candlestick, on the indicator signal or just like that
 
aleks557:
I wonder if you can add an animation to the chart in MQl5, like a guy who is pounding on the candlestick, on the indicator signal or just like that
The animation will have to be created manually from the many alternating .bmp images. They are usually drawn on a kanvas from an array of points.
 
barabashkakvn:
The animation will have to be created manually from many successive .bmp images. Or draw from an array of dots on canvas.

Greetings, Little Dwarf, where is "KANVAS"? I know that animation is done in Photoshop, but "KANVAS" has not been, how do I buy a ticket there?

Cause google led me to some kind of dairy.

 
aleks557:

Greetings, Little Dwarf, where is "KANVAS"? I know that animation is done in Photoshop, but "KANVAS" has not been, how do I buy a ticket there?

I don't know, but I googled it and found a dairy.

CCanvas isa class for creating custom graphics.

Examples of use, the path from MetaEditor: ...\MQL5\Scripts\Examples\Canvas\

 
aleks557:
I wonder if you can add an animation in MQl5 to a chart?

Here's more:

Forum on trading, automated trading systems and testing trading strategies

Questions from newbies

Renat, 2012.10.20 14:30

Did you know about the perfect hint of backbuffering in our kanvases and linking to an object on the screen?

We can draw frames perfectly, quickly and without artefacts. Take a look at the video example based on frame sequence generation in OpenCL Test.

Use a nice tactic:

  1. Create a Bitmap Label graphic object on the chart

       string objname ="OpenCL_"+IntegerToString(ChartID());
       string resname ="::Mandelbrot_"+IntegerToString(ChartID());
    //--- creating the object for graphics display
       ObjectCreate(0,objname,OBJ_BITMAP_LABEL,0,0,0);
       ObjectSetInteger(0,objname,OBJPROP_XDISTANCE,4);
       ObjectSetInteger(0,objname,OBJPROP_YDISTANCE,26);
    

  2. Create an empty graphical resource in memory and bind it to a previously created object:

    //--- create initial empty picture
       uint buf[];
    
       ArrayResize(buf,SIZE_X*SIZE_Y);
       ResourceCreate(resname,buf,SIZE_X,SIZE_Y,0,0,SIZE_X,COLOR_FORMAT_XRGB_NOALPHA);
       ObjectSetString(0,objname,OBJPROP_BMPFILE,resname);
    
    This is where the magic happens. The graphical object receives a direct binding to the graphical resource. And this binding is intelligent with caching, as it was specially created for quick paging and backbuffer handling.

  3. Now you can easily draw in your buffer without worrying about binding to an object on the screen

    //--- рисуем что хотим в buf
    ....
    
  4. And now it's time to display this updated bitmap on screen

          //--- saving the frame in memory and drawing it
          ResourceCreate(resname,buf,SIZE_X,SIZE_Y,0,0,SIZE_X,COLOR_FORMAT_XRGB_NOALPHA);
          ChartRedraw();
    
    To do this, we "rebuild" the resource (no rebuilding actually happens, because all sizes are the same), copy the new bitmap to it, and the change counters of this resource are incremented.

    Note that the graphical object objname itself isn't touched in any way as it's already associated with the resource.

    Then we call Screen Redraw via ChartRedraw which requires drawing of the graphical object. It is bound to our resource which it controls using the bitmap alteration counter. If the change counter of bitmap saved in the graphical object doesn't coincide with the counter of resource, the bitmap will be automatically copied to the graphical object and visualized in a protected way. If, however, the counters match, then the picture is shown without any changes.

This is a simple method of safe (from simultaneous access from MQL5 and the terminal rendering system itself) and quick work with rendering frames.

You have to try it.