Discussion of article "LifeHack for traders: Fast food made of indicators"

 

New article LifeHack for traders: Fast food made of indicators has been published:

If you have newly switched to MQL5, then this article will be useful. First, the access to the indicator data and series is done in the usual MQL4 style. Second, this entire simplicity is implemented in MQL5. All functions are as clear as possible and perfectly suited for step-by-step debugging.

Now, after 12 years, such claims seem strange but the history repeats itself. Just like in 2005, some traders declare that MQL5 is complicated for learning and developing strategies compared to MQL4. This means that the overall level of developing trading robots has grown substantially over the years thanks to the fact that the developer was not afraid to move on providing algorithmic traders with even more powerful tools of the C++ language. The new MQL5 allows programmers to check results of all operations in maximum detail (this is especially important for handling trades) and consume RAM on demand. The old MQL4 provided much less opportunities of that kind before it was improved to MQL5 level. Besides, the syntax itself was less strict.

I believe, that debates about MQL5 complexity will also pass into oblivion after a short while. But since many traders still feel nostalgic about "good old MQL4", we will try to show how familiar MQL4 functions may look if implemented in MQL5.

"MACD MQL4 style EA short.mh5" in tester


Author: Vladimir Karputov

 

Great...

 

The article is a small extract of another. Nothing has been done to make it work efficiently. No caching of indicators and time series. No High[i], Low[i], etc. No iCustom.

It was expected to see something completely different. Moreover, what is the point of fast food in Expert Advisors, if it is not even in the sources anyway?

   for(int i=PositionsTotal()-1;i>=0;i--)
      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
         if(m_position.Symbol()==m_symbol.Name())
           {
            //--- long position is opened
            if(m_position.PositionType()==POSITION_TYPE_BUY)
              {
               //--- should it be closed?
               if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious && 
                  MacdCurrent>(MACDCloseLevel*m_adjusted_point))
                 {
                  //--- close position and exit
                  if(!m_trade.PositionClose(m_position.Ticket()))
                     Print("PositionClose error ",m_trade.ResultRetcodeDescription());
                  return;
                 }
               //--- check for trailing stop
               if(TrailingStop>0)
                 {
                  if(m_position.PriceCurrent()-m_position.PriceOpen()>m_adjusted_point*TrailingStop)
                    {
                     if(m_position.StopLoss()<m_symbol.Bid()-m_adjusted_point*TrailingStop)
                       {
                        //--- modify position and exit
                        if(!m_trade.PositionModify(m_position.Ticket(),
                           m_symbol.NormalizePrice(m_position.PriceCurrent()-m_adjusted_point*TrailingStop),
                           m_position.TakeProfit()))
                           Print("PositionModify error ",m_trade.ResultRetcodeDescription());
                        return;
                       }
                    }
                 }
              }

            if(m_position.PositionType()==POSITION_TYPE_SELL)
              {
               //--- should it be closed?
               if(MacdCurrent<0 && MacdCurrent>SignalCurrent && 
                  MacdPrevious<SignalPrevious && MathAbs(MacdCurrent)>(MACDCloseLevel*m_adjusted_point))
                 {
                  //--- close position and exit
                  if(!m_trade.PositionClose(m_position.Ticket()))
                     Print("PositionClose error ",m_trade.ResultRetcodeDescription());
                  return;
                 }
               //--- check for trailing stop
               if(TrailingStop>0)
                 {
                  if((m_position.PriceOpen()-m_position.PriceCurrent())>(m_adjusted_point*TrailingStop))
                    {
                     if((m_position.StopLoss()>(m_symbol.Ask()+m_adjusted_point*TrailingStop)) || (m_position.StopLoss()==0.0))
                       {
                        //--- modify position and exit
                        if(!m_trade.PositionModify(m_position.Ticket(),
                           m_symbol.NormalizePrice(m_symbol.Ask()+m_adjusted_point*TrailingStop),
                           m_position.TakeProfit()))
                           Print("PositionModify error ",m_trade.ResultRetcodeDescription());
                        return;
                       }
                    }
                 }
              }
           }
Переход с MQL4 на MQL5
Переход с MQL4 на MQL5
  • 2010.05.11
  • Sergey Pavlov
  • www.mql5.com
Данная статья, построенная в форме справочника по функциям MQL4, призвана помочь переходу с MQL4 на MQL5. Для каждой функции языка MQL4 приведено описание и представлен способ ее реализации на MQL5, что позволит вам значительно ускорить перевод своих программ с MQL4 на MQL5. Для удобства функции разбиты на группы, как в документации по MQL4.
 
fxsaber:

The article is a small extract of another. Nothing has been done to make it work efficiently. No caching of indicators and time series. No High[i], Low[i], etc. No iCustom.

It was expected to see something completely different. Moreover, what is the point of fast food in Expert Advisors, if it doesn't even smell in the sources anyway?


Here is an example of a typical MQL4-ca - without reading or looking at the code, you go straight to the podium with flags :) .

 
Vladimir Karputov:

Here is an example of a typical MQL4-ca - without reading, without looking at the code, straight to the podium with flags :) .

Before commenting, I read not only the text of the article, but also all attached sources (including the analysis of IndicatorsMQL4.mqh VS IndicatorsMQL5.mqh).

 
fxsaber:

Before commenting, you have read not only the text of the article, but also all attached sources (including the analysis of IndicatorsMQL4.mqh VS IndicatorsMQL5.mqh).


You must have looked through (missed) the MQL5\Include\SimpleCall\Series.mqh file.

About caching - these are your personal guesses (expectations).

This article is not intended to deceive MQL4 users by "plug in my file and you can continue to work mindlessly in the style of MQL4", it shows how to transfer the old approach in addressing indicators to MQL5.

 
Vladimir Karputov:

You must have overlooked the MQL5\Include\SimpleCall\Series.mqh file.

Read it carefully. Where is High[i], etc.?

About caching - these are your personal guesses (expectations).

This article is not intended to deceive MQL4 users by "plug in my file and you can continue to work mindlessly in the style of MQL4", it shows how to transfer the old approach in addressing indicators to MQL5.

Where is iCustom? You thoughtlessly almost copied and pasted a part of another article and got a failure in performance. In fact, deceiving users that this is the cost of MQL4-style, not your implementation.

Here you have performance measurements showing that MQL4-style is not inferior to MQL5 in some issues. You could do the same with indicators.

Here is one of the realisations of time series. You can see that the author has made an effort, emphasising performance and moving away from MQL4-style (you can refine the idea if you want).

Высокопроизводительная библиотека iTimeSeries
Высокопроизводительная библиотека iTimeSeries
  • votes: 25
  • 2017.05.25
  • nicholishen
  • www.mql5.com
Одной из основных проблем с MQL5 до сих пор было удаление встроенных функций для работы с таймсериями. Несмотря на то, что такой подход расширил для программистов возможности разработки, он также замедлил работу из-за обязательного шага по созданию и удалению новых ячеек памяти каждый раз, когда требуется доступ к данным таймсерии.  Рассмотрим...
 
fxsaber:

Read it carefully. Where is High[i], etc.?

Where is iCustom? You thoughtlessly almost copied and pasted a part of another article and got a failure in performance. In fact, deceiving users that this is the cost of MQL4-style, not your implementation.

Here you have performance measurements showing that MQL4-style is not inferior to MQL5 in some issues. You could do the same with indicators.

Here is one of the realisations of time series. You can see that the author has tried to emphasise performance and slightly departed (it is more convenient for him) from MQL4-style (you can refine the idea if you want).


To get used to MQL5 faster, only iXXXX functions of series are left, as they have more complete parameters (symbol, timeframe, shift), which will easily replace the more highly specialised High[], etc. The goal is not for the user to continue mindlessly using MQL4, but to start slowly rewriting their MQL4 code.

iCustom was not even in the plans - only standard indicators were considered.

About caching - this is definitely not in the article for the general public.


Added: by the way, the feedback from users will make it clear whether High[] and similar functions are necessary or whether we can do without iXXXX series.

 
Vladimir Karputov:

The goal is not for the user to continue mindlessly using MQL4, but to slowly start rewriting his MQL4 code.

MQL4-style is pure MQL5. It is no worse than SB. Don't fight with windmills in your imagination. You don't fight with the StandardLibrary-Style.

iCustom was not even in the plans - only standard indicators were considered.

About caching - it is definitely not in the article for the general public.

In MT4 vs MT5 topics concerning indicators, standard indicators were the least discussed. Almost everyone talked about custom ones. Standard indicators were written decades ago and are irrevocably outdated. Working in advanced MQL5 with ancient indicators looks strange.

Caching should not have been explained in the article, but should have been done, since you have taken the objectivity of your conclusions in relation to MQL4-style.

A drop in testing speed with simultaneous access to more than one indicator;

 
Vladimir Karputov:

Added: by the way, user feedback will show whether High[] and similar features are needed or whether the iXXXX series can be dispensed with.

Make a poll and see the result without saying anything in the form of comments. The same applies even to such simple things as Bid/Ask variables.

 

The article should be called "how you can't write code trying to save MQL4 representation".

Hard horror with leaked handles (why close the indicator handle?) and amazing overhead (trying to recreate the indicator, falling inside the indicator manager). And enough people will copy it without looking and without understanding.

Besides, inefficient extraction of 1 value from the indicator.

I read the article completely, looked through the codes enough.