Tester supporting MG4 scripts and advisors - page 2

 
AlexeyVik:

Well, maybe the creators don't see the kind of difficulties that ordinary programmers face.

For example, I used to study BASIC in university and nothing else. I tried to use mql4 but now I don't have any problems with it. When I tried to use mql5, I wrote one simple indicator with less than 100 lines together with a mql5 indicator hat. In my opinion there is a difference and the difference is significant.

This is a myth and you know it.

Let's take the standard ATR.mq4 from MetaTrader 4. There are 104 lines there:

//+------------------------------------------------------------------+
//|                                                          ATR.mq4 |
//|                   Copyright 2005-2014, MetaQuotes Software Corp. |
//|                                              https://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright   "2005-2014, MetaQuotes Software Corp."
#property link        "https://www.mql4.com"
#property description "Average True Range"
#property strict

//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 1
#property  indicator_color1  DodgerBlue
//--- input parameter
input int InpAtrPeriod=14; // ATR Period
//--- buffers
double ExtATRBuffer[];
double ExtTRBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
  {
   string short_name;
//--- 1 additional buffer used for counting.
   IndicatorBuffers(2);
   IndicatorDigits(Digits);
//--- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtATRBuffer);
   SetIndexBuffer(1,ExtTRBuffer);
//--- name for DataWindow and indicator subwindow label
   short_name="ATR("+IntegerToString(InpAtrPeriod)+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//--- check for input parameter
   if(InpAtrPeriod<=0)
     {
      Print("Wrong input parameter ATR Period=",InpAtrPeriod);
      return(INIT_FAILED);
     }
//---
   SetIndexDrawBegin(0,InpAtrPeriod);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Average True Range                                               |
//+------------------------------------------------------------------+
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,limit;
//--- check for bars count and input parameter
   if(rates_total<=InpAtrPeriod || InpAtrPeriod<=0)
      return(0);
//--- counting from 0 to rates_total
   ArraySetAsSeries(ExtATRBuffer,false);
   ArraySetAsSeries(ExtTRBuffer,false);
   ArraySetAsSeries(open,false);
   ArraySetAsSeries(high,false);
   ArraySetAsSeries(low,false);
   ArraySetAsSeries(close,false);
//--- preliminary calculations
   if(prev_calculated==0)
     {
      ExtTRBuffer[0]=0.0;
      ExtATRBuffer[0]=0.0;
      //--- filling out the array of True Range values for each period
      for(i=1; i<rates_total; i++)
         ExtTRBuffer[i]=MathMax(high[i],close[i-1])-MathMin(low[i],close[i-1]);
      //--- first AtrPeriod values of the indicator are not calculated
      double firstValue=0.0;
      for(i=1; i<=InpAtrPeriod; i++)
        {
         ExtATRBuffer[i]=0.0;
         firstValue+=ExtTRBuffer[i];
        }
      //--- calculating the first value of the indicator
      firstValue/=InpAtrPeriod;
      ExtATRBuffer[InpAtrPeriod]=firstValue;
      limit=InpAtrPeriod+1;
     }
   else
      limit=prev_calculated-1;
//--- the main loop of calculations
   for(i=limit; i<rates_total; i++)
     {
      ExtTRBuffer[i]=MathMax(high[i],close[i-1])-MathMin(low[i],close[i-1]);
      ExtATRBuffer[i]=ExtATRBuffer[i-1]+(ExtTRBuffer[i]-ExtTRBuffer[i-InpAtrPeriod])/InpAtrPeriod;
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+


Let's take ATR.mq5 from MetaTrader 5. It has 96 lines.

//+------------------------------------------------------------------+
//|                                                          ATR.mq5 |
//|                        Copyright 2009, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright   "2009, MetaQuotes Software Corp."
#property link        "https://www.mql5.com"
#property description "Average True Range"
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots   1
#property  indicator_type1   DRAW_LINE
#property  indicator_color1  DodgerBlue
#property  indicator_label1  "ATR"
//--- input parameters
input int InpAtrPeriod=14;  // ATR period
//--- indicator buffers
double    ExtATRBuffer[];
double    ExtTRBuffer[];
//--- global variable
int       ExtPeriodATR;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
//--- check for input value
   if(InpAtrPeriod<=0)
     {
      ExtPeriodATR=14;
      printf("Incorrect input parameter InpAtrPeriod = %d. Indicator will use value %d for calculations.",InpAtrPeriod,ExtPeriodATR);
     }
   else ExtPeriodATR=InpAtrPeriod;
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtATRBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,ExtTRBuffer,INDICATOR_CALCULATIONS);
//---
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//--- sets first bar from what index will be drawn
   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,InpAtrPeriod);
//--- name for DataWindow and indicator subwindow label
   string short_name="ATR("+string(ExtPeriodATR)+")";
   IndicatorSetString(INDICATOR_SHORTNAME,short_name);
   PlotIndexSetString(0,PLOT_LABEL,short_name);
//--- initialization done
  }
//+------------------------------------------------------------------+
//| Average True Range                                               |
//+------------------------------------------------------------------+
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,limit;
//--- check for bars count
   if(rates_total<=ExtPeriodATR)
      return(0); // not enough bars for calculation
//--- preliminary calculations
   if(prev_calculated==0)
     {
      ExtTRBuffer[0]=0.0;
      ExtATRBuffer[0]=0.0;
      //--- filling out the array of True Range values for each period
      for(i=1;i<rates_total && !IsStopped();i++)
         ExtTRBuffer[i]=MathMax(high[i],close[i-1])-MathMin(low[i],close[i-1]);
      //--- first AtrPeriod values of the indicator are not calculated
      double firstValue=0.0;
      for(i=1;i<=ExtPeriodATR;i++)
        {
         ExtATRBuffer[i]=0.0;
         firstValue+=ExtTRBuffer[i];
        }
      //--- calculating the first value of the indicator
      firstValue/=ExtPeriodATR;
      ExtATRBuffer[ExtPeriodATR]=firstValue;
      limit=ExtPeriodATR+1;
     }
   else limit=prev_calculated-1;
//--- the main loop of calculations
   for(i=limit;i<rates_total && !IsStopped();i++)
     {
      ExtTRBuffer[i]=MathMax(high[i],close[i-1])-MathMin(low[i],close[i-1]);
      ExtATRBuffer[i]=ExtATRBuffer[i-1]+(ExtTRBuffer[i]-ExtTRBuffer[i-ExtPeriodATR])/ExtPeriodATR;
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+


There is no difference in size of 104 vs. 96 lines, even the advantage is on the side of MQL5.

That's how people transfer nonsense and myths from forum to forum.

 
Renat:

Doesn't mean at all that the language is the same.

The difference is only in a small set of functions (MT5 has better ones) and there are no major costs to master.

As for "I don't want to waste my time" and "I need it yesterday", I would like to remind you that a trading platform is an important tool to increase a trader's efficiency. When there is an obviously more effective and functional solution, not using it is a self-harm and self-deception with invented myths.

It's enough to compare trading strategy testers to forget about MT4 forever. I'm not joking and I'm not overreacting - it's real.

The stupidest principle of summing up positions in MT5 (and this means the impossibility to limit the simultaneous operation of several MTS on one symbol and one account without any tricks) has forever discouraged trading on it. Even when there will be more brokers providing MT5 on the real than there are fingers on hands.

And rewriting the code for MT5 only for the sake of a tester - sorry, but it is absurd.

 
evillive:

The stupidest principle of summing up positions in MT5 (which means the impossibility to limit the simultaneous operation of several MTS on one symbol and on one account without any tricks) has forever discouraged trading on it. Even when there will be more brokers providing MT5 on real than there are fingers on hands.

It is not absurd at all.

The advantages have been explained so many times that I don't want to repeat them. I've also repeatedly explained why "multiple MTS on a single symbol is self-defeating, a loss and an unrealistic situation for mass use".


And to rewrite the code for MT5 only for the sake of a tester - sorry, but it's absurd.

It's not absurd.

You are cutting back on your own opportunities and missing out on chances of development. Proving to yourself and others that a knowingly better, more functional and powerful system is worse than an old one with a bunch of flaws is doing yourself direct harm.

 
Renat:

Not at all means that the language is the same.

The only difference is a small set of functions (in MT5 they are better) and there are no major costs to master.

As for "I don't want to waste my time" and "I need it yesterday", I would like to remind you that a trading platform is an important tool to increase a trader's efficiency. When there is a knowingly more effective and functional solution nearby, not using it is harming yourself and deceiving yourself with invented myths.

It's enough to compare trading strategy testers to forget about MT4 forever. I'm not joking and I'm not overreacting - it's real.

Renat, how difficult is it to equate an mt4 tester with an mt5 tester?
 
Renat:

This is a myth and you know it.

Let's take the standard ATR.mq4 from MetaTrader 4. There are 104 lines there:


Let's take ATR.mq5 from MetaTrader 5. It's 96 lines.


There is no difference in size of 104 vs 96 lines, and even the advantage goes to MQL5.

That's how people transfer nonsense and myths from forum to forum.

My question is that the same indicator in mql4 took me an hour to write, and it took me a week to master writing the same code in mql5... It's not the number of quotes, it's understanding of programming approaches...

How different is the function of getting the value of the standard indicator in mql4 from the same function in mql5... I've almost lost my mind when I was dealing with it. Of course, you can offer courses in programming, but you have to take into account other factors that may not allow to go to such courses... And the cost, and age, and the distance from the venue or the cost of traffic in the case of online learning ... You never know...

 
AlexeyVik:
Renat, how difficult is it to equate mt4 tester with mt5 tester?
We won't touch 4, only the service part of integration with MQL5.community.
 
Renat:
We will not touch the Quartet, only the service part of integration with MQL5.community.
I didn't even ask if you're going to do it, so I guessed that you won't. I asked if it's hard to...
 
AlexeyVik:

That's not what I was saying, I was saying that I wrote the same indicator on mql4 in an hour, and it took me a week to learn how to write the same code on mql5... It's not the number of quotes, it's understanding of programming approaches...

How different is the function of getting the value of custom indicator in mql4 from the same function in mql5 ... I`ve been almost crazy trying to figure it out. Of course, you can offer courses in programming, but you have to take into account other factors that may not allow to go to such courses... And the cost, and age, and the distance from the venue or the cost of traffic in the case of online learning ... You never know...

Compare the two files and you'll find the minimum differences.

About the "one week to get the hang of it, nearly went crazy" - it's a red word on the forum. That's how myths are born.

 
AlexeyVik:
Only the language in it is so different that it takes no small amount of time to master it.
Fuck that. A month was enough.
 
Renat:

Compare the two files and you will find minimal differences.

The "one week to get the hang of it, I nearly went crazy" is just a red-letter phrase on the forum. That's how myths are born.

I will not prove that this is the truth. For a person who is not familiar with C++ programming and generally OOP it is rather difficult and not at all for the sake of red words or creation of a myth. Strange as it may seem, I understood it all in a week and wrote what I needed. And this is a completely different myth; it shows that mql5 can be easily mastered even by non-professionals, such as me.