Questions from Beginners MQL5 MT5 MetaTrader 5 - page 910

 
Fast528:

I haven't optimised anything in a while.

What does the Result column mean? I can't figure it out.

the test with 10k was


This is either a custom criterion or just a criterion from the expected list, opposite the setting labelled "Optimisation".

 
Aleksey Vyazmikin:

This is either a custom criterion or just a criterion from an assumed list, opposite the setting labelled "Optimisation".

nothing is clear)

where there is a small minus in profits and in the Result column slightly below the starting amount

 
Fast528:

nothing is clear)

where there is a slight minus in profits and in the Result column slightly below the starting amount

 
Aleksey Vyazmikin:

Thanks, I'll have a look tomorrow.

 
Fast528:

Thanks, I'll have a look tomorrow.

Happy to help.

 
Please advise how to find out the upper and lower value of the price on the chart, visually observable at any given time?
 
Aleksey Vyazmikin:
Please advise how to find out the maximum and minimum values of the chart price, visually observable at the moment?

CHART_PRICE_MIN

chart_prmin

double r/o modifier - subwindow number

CHART_PRICE_MAX

chart max

double r/o modifier - subwindow number

 
Vladimir Karputov:

CHART_PRICE_MIN

chart_prmin

double r/o modifier - subwindow number

CHART_PRICE_MAX

chart max

double r/o modifier - subwindow number

Thank you!

I understand that these values can only be obtained on the current chart. To obtain the information on the history, it will be necessary to move the chart one bar at a time?

 
Aleksey Vyazmikin:

Thank you!

I understand that these values can only be obtained on the current chart, and to obtain information on the history, you would need to move the chart one bar at a time?

You can useOnChartEvent and CHARTEVENT_CHART_CHANGE event identifier - any change of chart. You can check it in a timer (e.g. once per second).

Here is an example based on OnChartEvent and CHARTEVENT_CHART_CHANGE event identifier:

//+------------------------------------------------------------------+
//|                                             CHART_PRICE_xxxx.mq5 |
//|                              Copyright © 2018, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2018, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.00"
#property indicator_chart_window
#property indicator_plots 0
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {
//---

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   if(id==CHARTEVENT_CHART_CHANGE)
     {
      string text=(DoubleToString(ChartPriceMax(0,0),Digits())+"\n"+
                   DoubleToString(ChartPriceMin(0,0),Digits()));
      Comment(text);
     }
  }
//+----------------------------------------------------------------------+ 
//| Gets the value of chart minimum in the main window or in a subwindow | 
//+----------------------------------------------------------------------+ 
double ChartPriceMin(const long chart_ID=0,const int sub_window=0)
  {
//--- prepare the variable to get the result 
   double result=EMPTY_VALUE;
//--- reset the error value 
   ResetLastError();
//--- receive the property value 
   if(!ChartGetDouble(chart_ID,CHART_PRICE_MIN,sub_window,result))
     {
      //--- display the error message in Experts journal 
      Print(__FUNCTION__+", Error Code = ",GetLastError());
     }
//--- return the value of the chart property 
   return(result);
  }
//+----------------------------------------------------------------------+ 
//| Gets the value of chart maximum in the main window or in a subwindow | 
//+----------------------------------------------------------------------+ 
double ChartPriceMax(const long chart_ID=0,const int sub_window=0)
  {
//--- prepare the variable to get the result 
   double result=EMPTY_VALUE;
//--- reset the error value 
   ResetLastError();
//--- receive the property value 
   if(!ChartGetDouble(chart_ID,CHART_PRICE_MAX,sub_window,result))
     {
      //--- display the error message in Experts journal 
      Print(__FUNCTION__+", Error Code = ",GetLastError());
     }
//--- return the value of the chart property 
   return(result);
  }
//+------------------------------------------------------------------+
Files:
 
Vladimir Karputov:

Can be based on OnChartEvent and CHARTEVENT_CHART_CHANGE event identifier - any graph change. Can be checked in a timer (e.g. once per second).

Here is an example based on OnChartEvent and CHARTEVENT_CHART_CHANGE event identifier:

Thank you!

Reason: