Testing CGraphic - questions and suggestions - page 9

 
Dennis Kirichenko:

Anatoly, thank you very much! It helped on point 1. Yes, I missed theCAxis::MaxGrace(const double value) axis method.

Here's another short example:

   CAxis *x_axis=graph.XAxis();
   x_axis.AutoScale(true);
   x_axis.Min(0);
   x_axis.Max(m_max_data);
   x_axis.MinGrace(0.0);
   x_axis.MaxGrace(0.2);
   x_axis.DefaultStep(m_max_data/10);
 

Application #1827124.


 
Anatoli Kazharski:

Application #1827124.

The problem has been fixed as follows:

Support Team2018.01.15 14:30

The error appeared when safely calculating the remainder of division in the CAxis::Mod method.

There used to be a numerical method implemented there, without using the MathMod function, but your example showed that the accuracy of this method is not the best in some cases.

So I had to change this method to:

//+------------------------------------------------------------------+
//| Calculate the modulus (remainder) in a safe manner so that divide|
//| by zero errors are avoided                                       |
//+------------------------------------------------------------------+
double CAxis::Mod(const double x,const double y)
  {
//--- check 
   if(y==0)
      return(0);
//--- calculate modulus
   return (x>0)? MathMod(x,y): MathMod(x,y)+y;
  }

//---

The result with the same parameters:


 

Initialisation in the CGraphic expert.

If you create a graph in the Expert Advisor, e.g:

int OnInit()
  {
     
   CGraphic graphic;
   string name ="Graphic";   
   bool ch =graphic.Create(0,name,0,220,20,970,370);

   double x[24]={0,1,2,3,4,5,6,7,8,9,10};
   double y[24]={0,1,2,3,4,5,6,7,8,9,10};
   
   for(int i=0;i<10;i++)
     {
     y[i] =y[i]+Shift;
     }
   CCurve *curve=graphic.CurveAdd(x,y,CURVE_HISTOGRAM);
   curve.HistogramWidth(6);
   curve.Color(Green);
   curve.Name("Curve");
   
   graphic.CurvePlotAll();
   graphic.Update();
//   ChartRedraw();
   
  return(INIT_SUCCEEDED);       
  }

then when changing an external parameter, the graph disappears periodically. Not at the first time. You can change the parameter 3-5 times and it gets lost at random, and not forever. It can be found through switching timeframes or automated trading (enabled or disabled).

Can we make it not be lost?

 
Photic:

Initialisation in the CGraphic expert.

If you create a chart in Expert Advisor, for example:

then when the external parameter is changed, the graph disappears periodically. Not from the first time. It is possible to change the parameter 3-5 times and then it is randomly lost somewhere, and not forever. It can be found by switching timeframes or automatic trading (enabled - not enabled).

Can you make it so that it is not lost?

You create and destroy the object on the local level of the OnInit function.

Create one on a global level.
 

The problem was solved by reinstalling MT.

I can't get used to the fact that there may not be an error when an error occurs.

 

Can you tell me how to change the width of the legend, or remove the space allotted to it altogether?

 
How can I prevent some lines from being written in the legend? I just have a line that is points on the Y coordinate and I need to make these points in different colours, so it is a different coloured line and it shows the same information, although it is made with different lines, and I only need to put summary information about this line in the legend, there are many such different coloured lines. How can I do it?
 

And another question, why do I specify a colour "Red", but it is displayed on the chart as blue, while Green is displayed correctly?

if(TypeInfo=="TP_FP")
{
   graphicP.HistoryNameSize(Point_K);//Устанавливает размер шрифта имени кривой
   graphicP.HistorySymbolSize(Point_K);//Получить/установить размер символов условных обозначений  

   CCurve *A=graphicP.CurveAdd(X,Y,Green,CURVE_POINTS,N_Model+"("+N+")");//Создает и добавляет кривую на график
   A.PointsFill(true);//Устанавливает флаг, указывающий, нужно ли выполнять заливку для точек, определяющих кривую при отрисовке точками. 
   A.PointsType(POINT_VERTICAL_DASH);//Устанавливает флаг, указывающий на тип точек, использующихся при отрисовке кривой точками.
}

if(TypeInfo=="FN")
{
   //graphicP.HistoryNameSize(1);//Устанавливает размер шрифта имени кривой
   //graphicP.HistorySymbolSize(1);//Получить/установить размер символов условных обозначений  

   CCurve *A=graphicP.CurveAdd(X,Y,Red,CURVE_POINTS,"");//Создает и добавляет кривую на график
   A.PointsFill(false);//Устанавливает флаг, указывающий, нужно ли выполнять заливку для точек, определяющих кривую при отрисовке точками. 
   A.PointsType(POINT_VERTICAL_DASH);//Устанавливает флаг, указывающий на тип точек, использующихся при отрисовке кривой точками.
}



 
Aleksey Vyazmikin:

And another question, why do I specify a colour "Red", but it is displayed on the graph blue, while Green is displayed correctly?



I figured it out, the colour has to be set as follows

ColorToARGB(Red,256)
Reason: