Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1524

 
I’m new to backtesting. Trying to test out an Martingale based EA on MT4. For some reason my graph is off. When the EA Martingale’s to make up for a losing position, you should see big dips in the graph, but I never see that. I see big humps when I should be seeing big dips. Any thoughts?
Files:
IMG_1330.png  24 kb
 

Good afternoon! For some reason the strategy tester stopped working. Although it was working last night.

How can I fix it?

Regards, Alexander

 
MrBrooklin #:

Hi Alexei, I don't know, but I think I've made everything clear and understandable in my post:

Regards, Vladimir.

Hi. But it can't be fitted to the standard indicator... That's why I specified the problem.

 
Alexey Viktorov #:

Hi. BUT there is no way to fit the standard indicator... That's why I specified the problem.

Good morning, Alexey! Can you explain why it is impossible to fit?

Regards, Vladimir.

 
MrBrooklin #:

Good morning, Alexei! Can you explain why you can't put it in?

Regards, Vladimir.

Because the code is not available for the standard, or rather technical indicator.

Документация по MQL5: Технические индикаторы
Документация по MQL5: Технические индикаторы
  • www.mql5.com
Все функции типа iMA, iAC, iMACD, iIchimoku и т.п., создают в глобальном кеше клиентского терминала копию соответствующего технического индикатора...
 
Alexey Viktorov #:

Because the code is not available for the standard, or rather technical indicator.

Alexey, I apologise for my stupidity and cluelessness, but then this code, which I took from MetaEditor, what kind of code is it?

Regards, Vladimir.

//+------------------------------------------------------------------+
//|                                                    Alligator.mq5 |
//|                             Copyright 2000-2024, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2000-2024, MetaQuotes Ltd."
#property link      "https://www.mql5.com"

//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots   3
#property indicator_type1   DRAW_LINE
#property indicator_type2   DRAW_LINE
#property indicator_type3   DRAW_LINE
#property indicator_color1  Blue
#property indicator_color2  Red
#property indicator_color3  Lime
#property indicator_width1  1
#property indicator_width2  1
#property indicator_width3  1
#property indicator_label1  "Jaws"
#property indicator_label2  "Teeth"
#property indicator_label3  "Lips"
//--- input parameters
input int                InpJawsPeriod=13;               // Jaws period
input int                InpJawsShift=8;                 // Jaws shift
input int                InpTeethPeriod=8;               // Teeth period
input int                InpTeethShift=5;                // Teeth shift
input int                InpLipsPeriod=5;                // Lips period
input int                InpLipsShift=3;                 // Lips shift
input ENUM_MA_METHOD     InpMAMethod=MODE_SMMA;          // Moving average method
input ENUM_APPLIED_PRICE InpAppliedPrice=PRICE_MEDIAN;   // Applied price
//--- indicator buffers
double ExtJaws[];
double ExtTeeth[];
double ExtLips[];
//--- handles for moving averages
int    ExtJawsHandle;
int    ExtTeethHandle;
int    ExtLipsHandle;
//--- bars minimum for calculation
int    ExtBarsMinimum;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtJaws,INDICATOR_DATA);
   SetIndexBuffer(1,ExtTeeth,INDICATOR_DATA);
   SetIndexBuffer(2,ExtLips,INDICATOR_DATA);
//--- set accuracy
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//--- sets first bar from what index will be drawn
   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,InpJawsPeriod-1);
   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,InpTeethPeriod-1);
   PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,InpLipsPeriod-1);
//--- line shifts when drawing
   PlotIndexSetInteger(0,PLOT_SHIFT,InpJawsShift);
   PlotIndexSetInteger(1,PLOT_SHIFT,InpTeethShift);
   PlotIndexSetInteger(2,PLOT_SHIFT,InpLipsShift);
//--- name for DataWindow
   PlotIndexSetString(0,PLOT_LABEL,"Jaws("+string(InpJawsPeriod)+")");
   PlotIndexSetString(1,PLOT_LABEL,"Teeth("+string(InpTeethPeriod)+")");
   PlotIndexSetString(2,PLOT_LABEL,"Lips("+string(InpLipsPeriod)+")");
//--- get MA's handles
   ExtJawsHandle=iMA(NULL,0,InpJawsPeriod,0,InpMAMethod,InpAppliedPrice);
   ExtTeethHandle=iMA(NULL,0,InpTeethPeriod,0,InpMAMethod,InpAppliedPrice);
   ExtLipsHandle=iMA(NULL,0,InpLipsPeriod,0,InpMAMethod,InpAppliedPrice);
//--- bars minimum for calculation
   ExtBarsMinimum=InpJawsPeriod+InpJawsShift;
   if(ExtBarsMinimum<(InpTeethPeriod+InpTeethShift))
      ExtBarsMinimum=InpTeethPeriod+InpTeethShift;
   if(ExtBarsMinimum<(InpLipsPeriod+InpLipsPeriod))
      ExtBarsMinimum=InpLipsPeriod+InpLipsPeriod;
  }
//+------------------------------------------------------------------+
//|  Alligator OnCalculate 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[])
  {
   if(rates_total<ExtBarsMinimum)
      return(0);
//--- not all data may be calculated
   int calculated=BarsCalculated(ExtJawsHandle);
   if(calculated<rates_total)
     {
      Print("Not all data of ExtJawsHandle is calculated (",calculated," bars). Error ",GetLastError());
      return(0);
     }
   calculated=BarsCalculated(ExtTeethHandle);
   if(calculated<rates_total)
     {
      Print("Not all data of ExtTeethHandle is calculated (",calculated," bars). Error ",GetLastError());
      return(0);
     }
   calculated=BarsCalculated(ExtLipsHandle);
   if(calculated<rates_total)
     {
      Print("Not all data of ExtLipsHandle is calculated (",calculated," bars). Error ",GetLastError());
      return(0);
     }
//--- we can copy not all data
   int to_copy;
   if(prev_calculated>rates_total || prev_calculated<0)
      to_copy=rates_total;
   else
     {
      to_copy=rates_total-prev_calculated;
      if(prev_calculated>0)
         to_copy++;
     }
//--- get ma buffers
   if(IsStopped()) // checking for stop flag
      return(0);
   if(CopyBuffer(ExtJawsHandle,0,0,to_copy,ExtJaws)<=0)
     {
      Print("getting ExtJawsHandle is failed! Error ",GetLastError());
      return(0);
     }
   if(IsStopped()) // checking for stop flag
      return(0);
   if(CopyBuffer(ExtTeethHandle,0,0,to_copy,ExtTeeth)<=0)
     {
      Print("getting ExtTeethHandle is failed! Error ",GetLastError());
      return(0);
     }
   if(IsStopped()) // checking for stop flag
      return(0);
   if(CopyBuffer(ExtLipsHandle,0,0,to_copy,ExtLips)<=0)
     {
      Print("getting ExtLipsHandle is failed! Error ",GetLastError());
      return(0);
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
MrBrooklin #:

Alexei, excuse me for being stupid and clueless, but then this code I took from MetaEditor, what is this code?

Regards, Vladimir.

1 - technical (standard)

Getting the handle

int  iAlligator(
   string              symbol,            // имя символа
   ENUM_TIMEFRAMES     period,            // период
   int                 jaw_period,        // период для расчета челюстей
   int                 jaw_shift,         // смещение челюстей по горизонтали
   int                 teeth_period,      // период для расчета зубов
   int                 teeth_shift,       // смещение зубов по горизонтали
   int                 lips_period,       // период для расчета губ
   int                 lips_shift,        // смещение губ по горизонтали
   ENUM_MA_METHOD      ma_method,         // тип сглаживания
   ENUM_APPLIED_PRICE  applied_price      // тип цены или handle
   );

2 - custom. In spite of the fact that it comes with the terminal.

And this one is like this

int  iCustom(
   string           symbol,     // имя символа
   ENUM_TIMEFRAMES  period,     // период
   string           name        // папка/имя_пользовательского индикатора
   ...                          // список входных параметров индикатора
   );
 
Alexey Viktorov #:

1 - technical (staff)

2 - user. Despite the fact that it is supplied with the terminal.....

I see. Thanks for the clarification. I didn't think that the same indicator placed in different places has such a catastrophic difference. Probably they work differently?

Regards, Vladimir.

 
MrBrooklin #:
I guess they work differently, too, huh?

I will answer my own question. It turned out that with the same input parameters, both indicators show the same picture.

Regards, Vladimir.


 
ESTARIX backtesting. I am trying to test a Martingale based EA on MT4. For some reason my chart is not working. When the EA is martingaleing to offset a losing position, you should see big dips in the chart, but I don't see that. I see big humps when I should be seeing big dips. Any thoughts on this?
Your EA, when closing a series of positions, starts closing from the most profitable position. That's why the balance rises at first and then falls when the losing positions start closing. If you want to see failures, change the closing order.
Reason: