Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1025

 

Can you advise a proper zig-zag, please... Because I've been using one of these and it sometimes gets very wobbly...


 

Please tell me, I do not quite understand - in the tester chart is the following, all ticks are M1, start deposit 5000 but drawdown shows 62% (3325), it is obviously not on the chart. A discrepancy?

Is it the quality of modeling? How does the tester calculate this drawdown? If it calculates it, why can't it be seen on the equity curve?



 
Aleksey Mavrin:

If it calculates it, why does not it show on the equity curve?

MT4 does not show the green equity line until one order is closed.

Aleksey Mavrin:

The drawdown rate shows 62% (3325), while it is obviously not shown on the chart. Discrepancy?

The tester calculates the drawdown according to equity, but relative to the order with the maximum drawdown, i.e. maybe you had an open order in the tester and you averaged it, your total equity might have been in plus, but the most loss-making order was in big drawdown at a certain moment of testing


HH: The quality of modelling is very low, you are testing the TS on all ticks, but a very large TF is chosen for the testhttps://www.mql5.com/ru/articles/1486

 
Igor Makanu:

MT4 does not show the green equity line until one order is closed, as soon as it is closed, the green line will appear (MT5 does not have this drawback).

The tester considers the drawdown on equity, but relative to the order with a maximum drawdown, that is, you may have had an open order in the tester and you have averaged, your total equity may have been in the +, but the most loss-making order was in a certain moment of testing in a large deficit


ZS: the quality of the simulation is very low, you are testing the TS on all ticks, but a very large TF was chosen for the testhttps://www.mql5.com/ru/articles/1486

That's right, the averager. It is clearer now, thank you very much! The only thing about the equity line is.

I analyzed his trading chart (I mean visualizer) grid-average as it is, i.e. he has very frequent drawdowns and the equity line on the chart does not reflect this, for example here

trade 2018 Dec 04. trade 1238, on the chart this is near the second from the end vertical dashed line under which the trade number is 1251. There's no hint of any drawdown on the green equity line there.

I.e. it is still unclear how it is drawn, but I conclude that it is impossible to trust and we should stop using MT5)

R.S. I don't know why the simulation quality is so bad, TF is M1, all ticks.


 
Aleksey Mavrin:

That's right, the averager. That makes more sense now, thank you very much! The only thing about the equity line is.

I analyzed his trading chart (I mean visualizer) grid-average as it is, i.e. he has very frequent drawdowns, and the equity line on the chart does not reflect this, for example here

trade 2018 Dec 04. trade 1238, on the chart this is near the second from the end vertical dashed line under which the trade number is 1251. There's no hint of any drawdown on the green equity line there.

I.e. it is still unclear how it is drawn, but I conclude that it is impossible to trust and we should stop using MT5)

R.S. I don't know why the simulation quality is so bad, TF is M1, all ticks.


The MetaTrader 4 tester is very inferior to the MetaTrader 5 tester. It cannot show funds until something is closed - it only shows them at the moment of profit/loss taking. In your picture all short positions are closed at the same time, that is why there is no equity line between opening and closing in the report. If you had closed at least one position between opening andclosing the positions on your screenshot, the equity drawdown that you had at the time of closing would be reflected in your report. That is, the report would show two drawdowns - on the balance sheet from closing one position with a loss, and on the funds - from the drawdown of current funds due to the current floating loss on the funds of all open positions.

 
Aleksey Mavrin:

I.e. it is still unclear how it is drawn, but it gives rise to the conclusion that one cannot trust it in any way and should blame it on MT5)

you can trust, but you need to read the entire tester report

add your estimate of the drawdown to the code and display it in the log in OnDeinit(), if you are talking about how to check the tester in the calculation of the maximum drawdown, then something like this

double minOrderProfit = 0.0;

int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   Print("minOrderProfit = ",minOrderProfit);
  }
//+------------------------------------------------------------------+
void OnTick()
  {
   for(int i=0;i<OrdersTotal();i++)
   {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) minOrderProfit = fmin(minOrderProfit,OrderProfit());
   }

// основной код

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


ZS: not checked, but it should work

 
Igor Makanu:

you can trust, but you need to read the whole tester report

add your drawdown estimate to the code and output it to the log in OnDeinit(), if we are talking about how to check the tester in the calculation of the maximum drawdown, then something like this


ZS: not checked, but it should work

I got it, thanks. I'm collecting all statistics in my EAs and for tester-optimizer in general, I'm counting sharps coefficients and others, volatility and DD, etc. daily, monthly, total, of course, everything I can.

And this was an experiment with a robot from Market, I put it to check, because I know that such a curve chart can't exist with such mega-profits. I was convinced that I was right, i.e. because of the way the equity curve is displayed in MT4

I made sure I'm right, because of the way the equity curve is displayed in MT4, wrong assessment is made of the product capabilities (if you look at the trade chart), while the charts are poking around in the market, you get the message? :) s.s. they sell shit to people

 

Good afternoon.

Have written an indicator but realise there is a mistake!!! Question to the red horizontal line (from the beginning of the day session ).

I tried to use it for some reason but it did not work correctly in expert advisors. And it swears by the entry in EAs.

(2019.12.19 11:25:31.532 Session Day (EURUSDrfd,H1) array out of range in 'Session Day.mq5' (144,41)

Help from the hall...

Thanks in advance for the tip!


PS

RED LINE direction (session opening) is RIGHT, from today to yesterday!!!!!!!

//+------------------------------------------------------------------+
//|                                                  Session Day.mq5 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_plots   2
//---- plot ColorCandles
#property indicator_type1   DRAW_CANDLES
#property indicator_color1  White,Blue,Red
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
#property indicator_label1  "Open;High;Low;Close"
//----
#property indicator_type2   DRAW_LINE
#property indicator_color2  Red
#property indicator_style2  STYLE_SOLID
#property indicator_width2  3
#property indicator_label2  "Line open session"
//-----
input int     StartCandle = 100;         //Кол-во свечек для расчета средней
input int     StartBarDay = 0;           //Час начала торгового дня
input int     BarSession1 = 10;          //Чвс Открытия дневной сессии
input int     BarSession2 = 19;          //Чвс Закрытия дневной сессии
input bool    LevelOpenSession = true;   //Уровень открытия сессии дня
//---
double ExtOpenBuffer[];
double ExtHighBuffer[];
double ExtLowBuffer[];
double ExtCloseBuffer[];
double ExtBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtOpenBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,ExtHighBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,ExtLowBuffer,INDICATOR_DATA);
   SetIndexBuffer(3,ExtCloseBuffer,INDICATOR_DATA);
   SetIndexBuffer(4,ExtBuffer,INDICATOR_DATA);
//--- установим цвет контура и теней
   PlotIndexSetInteger(0,PLOT_LINE_COLOR,0,clrWhite);
//--- установим цвет тела для бычьей свечи
   PlotIndexSetInteger(0,PLOT_LINE_COLOR,1,clrBlue);
//--- установим цвет тела для медвежьей свечи
   PlotIndexSetInteger(0,PLOT_LINE_COLOR,2,clrRed);
//--- set accuracy
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
   if(Period()<PERIOD_H4)
      IndicatorSetString(INDICATOR_SHORTNAME,"Session Day \nOpen session: "+string(BarSession1)+" hour \nClose session: "+string(BarSession2)+" hour");
   else
      IndicatorSetString(INDICATOR_SHORTNAME,"Session Day");
   int bars=iBars(NULL,_Period);
   for(int b=0; b<5; b++)
      PlotIndexSetInteger(b,PLOT_DRAW_BEGIN,bars-StartCandle);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   int i;
   if(rates_total<24)
      return(0);
   MqlDateTime tm;
//----
   if(prev_calculated==0)
     {
      ArrayInitialize(ExtOpenBuffer,EMPTY_VALUE);
      ArrayInitialize(ExtHighBuffer,EMPTY_VALUE);
      ArrayInitialize(ExtLowBuffer,EMPTY_VALUE);
      ArrayInitialize(ExtCloseBuffer,EMPTY_VALUE);
      ArrayInitialize(ExtBuffer,EMPTY_VALUE);
      i=0;
     }
   else
      i=prev_calculated-1;
//----
   while(i<rates_total && !IsStopped())
     {
      TimeToStruct(time[i],tm);
      if(Period()==PERIOD_MN1 && (tm.mon==4 || tm.mon==8 || tm.mon==12))
        {
         ExtOpenBuffer[i]=open[i];
         ExtHighBuffer[i]=high[i];
         ExtLowBuffer[i]=low[i];
         ExtCloseBuffer[i]=close[i];
        }
      if(Period()==PERIOD_W1 && tm.mon>=1 && tm.mon<=12 && tm.day>=1 && tm.day<8)
        {
         ExtOpenBuffer[i]=open[i];
         ExtHighBuffer[i]=high[i];
         ExtLowBuffer[i]=low[i];
         ExtCloseBuffer[i]=close[i];
        }
      if(Period()==PERIOD_D1 && tm.day_of_week==1)
        {
         ExtOpenBuffer[i]=open[i];
         ExtHighBuffer[i]=high[i];
         ExtLowBuffer[i]=low[i];
         ExtCloseBuffer[i]=close[i];
        }
      if(Period()==PERIOD_H4 && tm.hour==StartBarDay && tm.min==0)
        {
         ExtOpenBuffer[i]=open[i];
         ExtHighBuffer[i]=high[i];
         ExtLowBuffer[i]=low[i];
         ExtCloseBuffer[i]=close[i];
        }
      if(Period()<=PERIOD_H1 && tm.hour==BarSession1 && tm.min==0)
        {
         ExtOpenBuffer[i]=open[i];
         ExtHighBuffer[i]=high[i];
         ExtLowBuffer[i]=low[i];
         ExtCloseBuffer[i]=close[i];
        }
      if(Period()<=PERIOD_H1 && tm.hour==BarSession2 && tm.min==0)
        {
         ExtOpenBuffer[i]=open[i];
         ExtHighBuffer[i]=high[i];
         ExtLowBuffer[i]=low[i];
         ExtCloseBuffer[i]=close[i];
        }


                     ПРОБЛЕМА !!!!!
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      if(LevelOpenSession==true && Period()==PERIOD_H1 && tm.hour==BarSession1 && tm.min==0)
         for(int j=0; j<24; j++)
           {
            ExtBuffer[i-j]=open[i];
            if(ExtBuffer[i-j]!=ExtBuffer[i-j-1])
               ExtBuffer[i-j-1]=EMPTY_VALUE;
           }
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      //---
      i++;
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+




 
kopeyka2:

Good afternoon.

Have written an indicator but realise there is a mistake!!! Question to the red horizontal line (from the beginning of the day session ).

I tried to use it for some reason but it did not work correctly in expert advisors. And it swears by the entry in EAs.

(2019.12.19 11:25:31.532 Session Day (EURUSDrfd,H1) array out of range in 'Session Day.mq5' (144,41)


 ExtBuffer[i-j]=open[i];
            if(ExtBuffer[i-j]!=ExtBuffer[i-j-1])
               ExtBuffer[i-j-1]=EMPTY_VALUE;

at this point, at some point, you access a negative array index. check setting and checking all boundary conditions for i, j

 
Artyom Trishkin:

The MetaTrader 4 tester is considerably inferior to MetaTrader 5. It cannot show funds until something is closed - it only shows them at the moment of profit/loss taking. In your picture all short positions have been closed at once, that is why there is no equity line between opening and closing in the report. If you had closed at least one position between opening and closing the positions on your screenshot, the equity drawdown that you had at the time of closing would be reflected in your report. That is, the report would show two drawdowns - on the balance sheet from closing one position with a loss, and on the funds - from the drawdown of current funds due to the current floating loss on the funds of all open positions.

That's quite a clear description, thank you. Didn't notice the post at first for some reason(

And a question then) - Requesting inside the tester functions of information about account status such as AccountEquity, etc. - it gives a correct picture regardless of whether some position closed or not?

For example, if long-term trades are opened and equity drawdown is recorded every day, the tester will not cheat?