Discussion of article "Visualize this! MQL5 graphics library similar to 'plot' of R language" - page 3

[Deleted]  
Roman Konopelko:

Good day!

CustomPlotFunction mode is implemented in the library for similar purposes, the example of using it implements approximately what you are interested in.

P.S. More details about it are written in forum .


Great, thanks :)
[Deleted]  

Is there a way to plot the X axis labels as a datetime series?

 
Pablo Rego:

Is there a way to plot the X axis labels as a datetime series?

Example:

#include <Graphics/Graphic.mqh>
double arrX[];
double arrY[];
//---
string TimeFormat(double x,void*data)
  {
   return(TimeToString((datetime)arrX[ArraySize(arrX)-(int)x-1]));
  }
//+------------------------------------------------------------------+
void OnStart()
  {
   MqlRates rates[];
   CopyRates(Symbol(),Period(),0,100,rates);
   ArraySetAsSeries(rates,true);
   int size=ArraySize(rates);
   ArrayResize(arrX,size);
   ArrayResize(arrY,size);
   for(int i=0; i<size;++i)
     {
      arrX[i]=(double)rates[i].time;
      arrY[i]=rates[i].close;
     }
   CGraphic graphic;
   graphic.Create(0,"Rates",0,30,30,780,380);
   CCurve *curve=graphic.CurveAdd(arrY,CURVE_LINES,"Close");
   CAxis *xAxis=graphic.XAxis();
   xAxis.AutoScale(false);
   xAxis.Type(AXIS_TYPE_CUSTOM);
   xAxis.ValuesFunctionFormat(TimeFormat);
   xAxis.DefaultStep(20.0);
   curve.Visible(true);
   graphic.Redraw();
   graphic.Update();
  }

Result:


 

Is it possible to draw labels on X axis in reverse (reverse) order?

To see time-series indexes, for example.

 
Dennis Kirichenko:

Is it possible to draw labels on X axis in reverse (reverse) order?

To see time-series indexes, for example.

There is no quick solution in the form of calling one function that will do everything by itself. As in , you need to create your own function for drawing values and pass it to the ValuesFunctionFormat method.
 

Is there any similar library in mql4??

[Deleted]  

Can you tell me if it is possible to set the background transparency, maybe in the base class, maybe something to tweak?

 
Maxim Dmitrievsky:

Can you tell me if it is possible to set the background transparency, maybe in the base class? I couldn't find it easily


Only if you modify the CGraphic class (only direct editing is wrong, you need inheritance, the example here is just for quickness).

//+------------------------------------------------------------------+
//| Create graphic|
//+------------------------------------------------------------------+
bool CGraphic::Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2)
  {
//--- check object name 
   if(ObjectFind(chart,name)>=0)
      return(false);
//--- preliminary calculation
   int width=x2-x1;
   int height=y2-y1;
   if(width>0 && height>0)
     {
      m_width=width;
      m_height=height;
      //--- create object
      if(!ObjectCreate(chart,name,OBJ_BITMAP_LABEL,subwin,0,0))
         return(false);
      //--- customize object
      if(!ObjectSetInteger(chart,name,OBJPROP_XDISTANCE,x1) || 
         !ObjectSetInteger(chart,name,OBJPROP_YDISTANCE,y1))
        {
         ObjectDelete(chart,name);
         return(false);
        }
      //--- attach object
      if(!m_canvas.Attach(chart,name,width,height,COLOR_FORMAT_ARGB_NORMALIZE))
        {
         ObjectDelete(chart,name);
         return(false);
        }
     }
//--- success
   return(true);
  }

After that you can control the colour:

   CGraphic graphic;
   graphic.Create(0,"Graphic",0,10,10,680,360);

   graphic.BackgroundColor(ColorToARGB(clrRed,150));
   graphic.GridBackgroundColor(ColorToARGB(clrBlue,150));

:

Example

[Deleted]  
Vladimir Karputov:

Only if you make a change to the CGraphic class (only direct editing is wrong, you need inheritance, the example here is purely for quickness)

After that you can control the colour:

:



thanks, I'll deal with inheritance :)

[Deleted]  

How to make that when changing inputs in the Expert Advisor(REASON_PARAMETERS), the chart does not generate an error and refreshes with new parameters? If I switch tf or change symbols, everything is ok, if I change parameters, the error is invalid pointer. The number of curves changes in the parameters and it is on them that the pointers are incorrect.

if it is not clear I can give you an example )