Features of the mql5 language, subtleties and tricks - page 16

 
Andrey Dik:
Can you make the "Open chart" command in the "Backtest" tab automatically add all the indicators that were used in the EA with the appropriate parameters to the opened chart after testing?

Not yet.

For now you can save the template of visual testing and apply it in the client terminal

 
Slawa:

Not yet.

For now you can save a visual testing template and apply it in the client terminal

And if you do in the Expert Advisor in OnDeinit

ChartSaveTemplate ()


with the name tester.tpl then after you open the chart using the"Open Chart" command you will get what you need?

 
Andrey Dik:

But if you do in the Expert Advisor in OnDeinit

ChartSaveTemplate ().


If you open the chart using the"Open Chart" command, will you get what you need?

No. ChartSaveTemplate will save the template in the local Files folder of the tester agent.

I meant manually save the template from the renderer through the main menu.

Tester.tpl works only one way - from the client terminal to the visualizer

 
Slawa:

No. ChartSaveTemplate will save the template to the local Files folder of the tester agent

I meant manually save the template from the visualizer through the main menu.

Tester.tpl only works one way - from the client terminal to the visualizer

No, it's too cumbersome, it requires a lot of gestures, and it's often too expensive to do every time a visual test just to save the template, especially when you have to do it often...

It means that we need a regular possibility to open a chart after testing immediately with indicators.

SZY. In the tester does not work:

//——————————————————————————————————————————————————————————————————————————————
void OnDeinit (const int reason)
{
  if(ChartSaveTemplate(0, "testersdfsdfsdfsdf"))
    Print (__FUNCTION__ + ": Шаблон сохранён");
  else
    Print (__FUNCTION__ + ": Шаблон НЕ сохранён");
    
  EventKillTimer ();
}
//——————————————————————————————————————————————————————————————————————————————

//——————————————————————————————————————————————————————————————————————————————
double OnTester ()
{
  if(ChartSaveTemplate(0, "testersdfsdfsdfsdf"))
    Print (__FUNCTION__ + ": Шаблон сохранён");
  else
    Print (__FUNCTION__ + ": Шаблон НЕ сохранён");
  return (-DBL_MAX);
}
//——————————————————————————————————————————————————————————————————————————————

result:

2017.03.07 12:22:15.422 Core 1 2017.03.06 23:58:59 OnTester: Template NOT saved
2017.03.07 12:22:15.422 Core 1 final balance 1129.18 USD
2017.03.07 12:22:15.422 Core 1 OnTester result -1.797693134862316e+308
2017.03.07 12:22:15.422 Core 1 2017.03.06 23:58:59 OnDeinit: Template NOT saved

 
void OnStart()
  {
   int indic = iCustom(Symbol(), Period(), "Examples\\ATR", 7, PRICE_CLOSE, clrGreen);
   ChartIndicatorAdd(0, 1, indic);  
   Sleep(10000);
  }

It is not possible to set the color of the indicator this way.

So why do some people say "it's not a bug, it's a feature"?

However, the official answer has satisfied me completely:

We will think about how to change the indicator color and style from MQL5 program.

In the meantime, use input variables of the color type to set the indicator color

 
Roffild:
void OnStart()
  {
   int indic = iCustom(Symbol(), Period(), "Examples\\ATR", 7, PRICE_CLOSE, clrGreen);
   ChartIndicatorAdd(0, 1, indic);  
   Sleep(10000);
  }

It is not possible to set the color of the indicator this way.

So why do some people say "it's not a bug, it's a feature"?

However, the official answer is completely satisfactory to me:

Because you cannot set the display properties (the drawing part) through the indicator handle (the calculation part). A bug is when something is written one way and it works in another way.

A different approach is needed here. Access to the indicator by short name, as in the ChartIndicatorXXX function group. Something like ChartIndicatorSetInteger(chart_id,sub_window,indicator_name,PROP_COLOR,mod,value)

We've already thought about it, but haven't got around to it yet.

 

Why do you need to set something through a handle? The color is set in the indicator itself through the PLOT_LINE_COLOR property.

The indicator_colorN only sets the original color that is changed through PLOT_LINE_COLOR.

indicator_colorN is no different from input when calling the indicator and then setting it via PLOT_LINE_COLOR.

You should not allow to change such properties through a handle.

And it is time to allow to set indicator_buffers dynamically.

 
Roffild:

Why do you need to set something through a handle? The color is set in the indicator itself through the PLOT_LINE_COLOR property.

The indicator_colorN only sets the original color that is changed through PLOT_LINE_COLOR.

indicator_colorN is no different from input when calling the indicator and then setting it via PLOT_LINE_COLOR.

You should not allow to change such properties through a handle.

And it's time to allow setting indicator_buffers dynamically.

I do not need to mention the handle. I have told myself that the handle cannot be used to set drawing properties. And I explained why.

Do not forget that besides custom indicators there are also built-in indicators, that must also change color after adding them to the chart.

 

I only suggest extending the functions of the indicator call:

iCustom(... inputs, PRICE_CLOSE,
         [color color1, int width1, int style1]... );

iAlligator(... params, PRICE_CLOSE,
         [color color1, int width1, int style1]... );
Nothing else needs to be added.
 
Roffild:

I only suggest extending the functions of the indicator call:

Uh, why when you can't see it anyway?
Reason: