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

 
Rashid Umarov:

PS I ran the standard MACD Sample on USDJPY M30 2017.02.01-2018.01.18 "All ticks" (as in the article) MetaQuotes-Demo.

How can you fit into 8 seconds? Especially in 1 second?

Forum on trading, automated trading systems and testing trading strategies

Discussion of the article "LifeHack for trader: cooking fast food from indicators"

fxsaber, 2018.01.26 11:06 AM.

Did not do anything. Run it as is. In the above logs all the data to reproduce. Your result should be completely the same as mine in terms of profit. And by performance not much different.

 
Rashid Umarov:
Really? When you claim to have found an error or a problem in my article that I was paid money for, I will definitely check it out. In the meantime, let's not "let's." Because you're making it sound like you're being patronising.
 
fxsaber:

Made the MACD SaMple from the delivery on your settings. And where does EURO in the balance come from, isn't that the point?

And the testing time is still much longer than yours.

2018.01.26 13:34:10.520 Core 1  authorized (agent build 1755)
2018.01.26 13:34:10.522 Tester  EURUSD,M1 (MetaQuotes-Demo): testing of Experts\Examples\MACD\MACD Sample.ex5 from 2017.09.01 00:00 to 2018.01.26 00:00

2018.01.26 13:34:16.792 Core 1  EURUSD,M1 (MetaQuotes-Demo): generating based on real ticks
2018.01.26 13:34:16.792 Core 1  EURUSD,M1: testing of Experts\Examples\MACD\MACD Sample.ex5 from 2017.09.01 00:00 to 2018.01.26 00:00 started with inputs:
2018.01.26 13:34:16.792 Core 1    InpLots=0.1
2018.01.26 13:34:16.792 Core 1    InpTakeProfit=50
2018.01.26 13:34:16.792 Core 1    InpTrailingStop=30
2018.01.26 13:34:16.792 Core 1    InpMACDOpenLevel=3
2018.01.26 13:34:16.792 Core 1    InpMACDCloseLevel=2
2018.01.26 13:34:16.792 Core 1    InpMATrendPeriod=26


2018.01.26 13:25:46.482 Core 1  final balance 10168.90 USD
2018.01.26 13:25:46.482 Core 1  EURUSD,M1: 9753093 ticks, 147480 bars generated. Environment synchronized in 0:00:02.610. 
Test passed in 0:00:19.062 (including ticks preprocessing 0:00:02.078).
2018.01.26 13:25:46.482 Core 1  EURUSD,M1: total time from login to stop testing 0:00:21.672 (including 0:00:02.610 for history data synchronization)
2018.01.26 13:25:46.482 Core 1  600 Mb memory used including 44 Mb of history data, 256 Mb of tick data
 

On the time frame from the article, on EURUSD,M30 and USDJPY,M30

MACD Sample One value at a time.mq5:

final balance 100180.01 USD
EURUSD,M30: 26390728 ticks, 12510 bars generated. Environment synchronized in 0:00:00.125. Test passed in 0:00:41.016 (including ticks preprocessing 0:00:02.328).
EURUSD,M30: total time from login to stop testing 0:00:41.141 (including 0:00:00.125 for history data synchronization)
756 Mb memory used including 1.88 Mb of history data, 512 Mb of tick data

final balance 99523.31 USD
USDJPY,M30: 29801706 ticks, 11837 bars generated. Environment synchronized in 0:00:00.032. Test passed in 0:01:00.937 (including ticks preprocessing 0:00:02.735).
USDJPY,M30: total time from login to stop testing 0:01:00.969 (including 0:00:00.032 for history data synchronization)
819 Mb memory used including 1.88 Mb of history data, 576 Mb of tick data


MACD Sample 4 to 5 MQL4 style.mq5:

final balance 100192.51 USD
EURUSD,M30: 26390728 ticks, 12510 bars generated. Environment synchronized in 0:00:00.140. Test passed in 0:01:37.969 (including ticks preprocessing 0:00:02.329).
EURUSD,M30: total time from login to stop testing 0:01:38.109 (including 0:00:00.140 for history data synchronization)
755 Mb memory used including 1.88 Mb of history data, 512 Mb of tick data

final balance 99550.10 USD
USDJPY,M30: 29801706 ticks, 11837 bars generated. Environment synchronized in 0:00:00.031. Test passed in 0:01:51.328 (including ticks preprocessing 0:00:02.500).
USDJPY,M30: total time from login to stop testing 0:01:51.359 (including 0:00:00.031 for history data synchronization)
819 Mb memory used including 1.88 Mb of history data, 576 Mb of tick data

The test time differs twice. And it is not 8 or 1 second.

If you compare the balances - yes, there is a slight difference in the numbers, but it is not noticeable on the chart.

 
Vasiliy Sokolov:

In fact, the description of this topic is seen here on a slightly different plane:

  • Thousands of indicators have already been written, accessed via iCustom with allocation of appropriate buffers/handles and so on and so forth. This is a slow and resource-intensive story;
  • An indicator can be implemented as a pure function inside an Expert Advisor - in this case the required value will be calculated much faster and will require less memory.

The idea is to write some kind of interface that would allow unified access to any custom indicators , but if the indicator is implemented as a separate pure function, the reference is made to this function instead of the handle. As a result, we get a good acceleration and at the same time we do not lose access to any arbitrary indicator. This is an interesting topic, I would even take it up.

Try it, it's interesting to see if it's worth it. I would like an approach of this type - we take OnCalculate out of the indicator, modify it slightly under a new name, add it to the indicator code and now we can pull this function as a bibilio function, passing parameters from the Expert Advisor to it. Right?
 
Rashid Umarov:
...I would like an approach of this type - we take OnCalculate out of the indicator, slightly modify it under a new name, add it to the indicator code and now we can pull this function as a bibilio function, passing parameters from the Expert Advisor to it. Right?
We need to think about implementation. Now it is difficult to say how it can be.
 
Rashid Umarov:
Try it, it's interesting to see if it's worth it. I would like an approach of this type - we take OnCalculate out of the indicator, modify it slightly under a new name, add it to the indicator code and now we can pull this function as a bibilio function, passing parameters from the Expert Advisor to it. Right?

I did this for iRSIOnArray(), which is not in mql5. It works in the indicator. To call it from the Expert Advisor, it is necessary to do not so straightforwardly.

//+------------------------------------------------------------------+
//| Relative Strength Index on array|
//+------------------------------------------------------------------+
template<typename T>
int RSIOnArray(const int rates_total,
               const int prev_calculated,
               const int begin,
               const int period,
               const T &price[],
               double &buffer_pos[],
               double &buffer_neg[],
               double &buffer_rsi[])
  {
   int   i;
   T     diff;
//--- check for rates count
   if(period<1 || rates_total-begin<period) return(0);
//--- save as_series flags
   bool as_series_price=ArrayGetAsSeries(price);
   bool as_series_rsi=ArrayGetAsSeries(buffer_rsi);
   if(as_series_price)
      ArraySetAsSeries(price,false);
   if(as_series_rsi)
     {
      ArraySetAsSeries(buffer_rsi,false);
      ArraySetAsSeries(buffer_pos,false);
      ArraySetAsSeries(buffer_neg,false);
     }
//--- preliminary calculations
   int pos=prev_calculated-1;
   if(pos<=period)
     {
      //--- first RSIPeriod values of the indicator are not calculated
      buffer_rsi[0]=0.0;
      buffer_pos[0]=0.0;
      buffer_neg[0]=0.0;
      T SumP=0.0;
      T SumN=0.0;
      for(i=1; i<=period; i++)
        {
         buffer_rsi[i]=0.0;
         buffer_pos[i]=0.0;
         buffer_neg[i]=0.0;
         diff=price[i]-price[i-1];
         SumP+=(diff>0 ? diff : 0);
         SumN+=(diff<0 ?-diff : 0);
        }
      //--- calculate first visible value
      buffer_pos[period]=double(SumP/period);
      buffer_neg[period]=double(SumN/period);
      
      buffer_rsi[period]=100.0-(100.0/(1.0+buffer_pos[period]/(buffer_neg[period]>0 ? buffer_neg[period] : DBL_MIN)));
      //--- prepare the position value for main calculation
      pos=period+1;
     }
//--- the main loop of calculations
   for(i=pos;i<rates_total && !IsStopped();i++)
     {
      diff=price[i]-price[i-1];
      buffer_pos[i]=(buffer_pos[i-1]*(period-1)+(diff>0.0 ? diff : 0.0))/period;
      buffer_neg[i]=(buffer_neg[i-1]*(period-1)+(diff<0.0 ?-diff : 0.0))/period;
      buffer_rsi[i]=100.0-100.0/(1+buffer_pos[i]/(buffer_neg[i]>0 ? buffer_neg[i] : DBL_MIN));
     }
//--- restore as_series flags
   if(as_series_price) ArraySetAsSeries(price,true);
   if(as_series_rsi)
     {
      ArraySetAsSeries(buffer_rsi,true);
      ArraySetAsSeries(buffer_pos,true);
      ArraySetAsSeries(buffer_neg,true);
     }
//---
   return(rates_total);
  }
//+------------------------------------------------------------------+
 

Forum on trading, automated trading systems and testing trading strategies

Discussion of the article "LifeHack for trader: cooking fast food from indicators"

Rashid Umarov, 2018.01.26 11:30 AM

Made MACD SaMple from the supply on your settings. Where is EURO in the balance from, is that not the point?

That's not the point. EUR from here


And the testing time is still much longer than yours.

2018.01.26 13:34:10.520 Core 1  authorized (agent build 1755)
2018.01.26 13:34:10.522 Tester  EURUSD,M1 (MetaQuotes-Demo): testing of Experts\Examples\MACD\MACD Sample.ex5 from 2017.09.01 00:00 to 2018.01.26 00:00

2018.01.26 13:34:16.792 Core 1  EURUSD,M1 (MetaQuotes-Demo): generating based on real ticks
2018.01.26 13:34:16.792 Core 1  EURUSD,M1: testing of Experts\Examples\MACD\MACD Sample.ex5 from 2017.09.01 00:00 to 2018.01.26 00:00 started with inputs:
2018.01.26 13:34:16.792 Core 1    InpLots=0.1
2018.01.26 13:34:16.792 Core 1    InpTakeProfit=50
2018.01.26 13:34:16.792 Core 1    InpTrailingStop=30
2018.01.26 13:34:16.792 Core 1    InpMACDOpenLevel=3
2018.01.26 13:34:16.792 Core 1    InpMACDCloseLevel=2
2018.01.26 13:34:16.792 Core 1    InpMATrendPeriod=26


2018.01.26 13:25:46.482 Core 1  final balance 10168.90 USD
2018.01.26 13:25:46.482 Core 1  EURUSD,M1: 9753093 ticks, 147480 bars generated. Environment synchronized in 0:00:02.610. 
Test passed in 0:00:19.062 (including ticks preprocessing 0:00:02.078).
2018.01.26 13:25:46.482 Core 1  EURUSD,M1: total time from login to stop testing 0:00:21.672 (including 0:00:02.610 for history data synchronization)
2018.01.26 13:25:46.482 Core 1  600 Mb memory used including 44 Mb of history data, 256 Mb of tick data

Here is my log with your settings

EURUSD,M1 (MetaQuotes-Demo): generating based on real ticks
EURUSD,M1: testing of Experts\Examples\MACD\MACD Sample.ex5 from 2017.09.01 00:00 to 2018.01.26 00:00 started with inputs:
  InpLots=0.10
  InpTakeProfit=50
  InpTrailingStop=30
  InpMACDOpenLevel=3
  InpMACDCloseLevel=2
  InpMATrendPeriod=26

final balance 10000168.90 USD
EURUSD,M1: 9753093 ticks, 147480 bars generated. Environment synchronized in 0:00:00.031. Test passed in 0:00:06.302.
EURUSD,M1: total time from login to stop testing 0:00:06.333 (including 0:00:00.031 for history data synchronization)
571 Mb memory used including 44 Mb of history data, 256 Mb of tick data


Why it is 3.5 times faster for me (caching was removed by recompilation before backtest) - I don't know. Configuration

2018.01.26 11:45:38.151 Terminal        Alpari Limited MT5 x64 build 1755 started (Alpari Limited)
2018.01.26 11:45:38.151 Terminal        Windows 7 Service Pack 1 (build 7601) x64, IE 9, Intel Core i7-2700 K  @ 3.50 GHz, Memory: 10147 / 16301 Mb, Disk: 3 / 29 Gb, GMT+2

Let's find out the reasons! I think this is very important. I don't have a HDD (only SSD). Maybe that's the issue. But then it's VERY bad for the MT5. The comp is very ancient - five years old for sure. That's why it's weird.

 
Vladimir Karputov:

The test times are twice as different. And it is not 8 or 1 second.

Show the configuration lines from the Terminal startup log.

 
fxsaber:

Why I have 3.5 times faster execution (caching removed by recompilation before backtest) - I don't know. Configuration

Let's find out the reasons! I think this is very important. I don't have a HDD (only SSD). Maybe that's the issue. But then it is VERY bad for the MT5. The comp is very ancient - five years old for sure. That's why it's weird.

Here's my comp, no SSD

MetaTrader 5 x64 build 1755 started (MetaQuotes Software Corp.)
Windows 10 (build 16299) x64, IE 11, UAC, Intel Core i7  920 @ 2.67 GHz, Memory: 6613 / 12277 Mb, Disk: 156 / 270 Gb, GMT+3

Looked in all the posts - the number of ticks is the same

2018.01.26 13:25:46.482 Core 1  final balance 10168.90 USD
2018.01.26 13:25:46.482 Core 1  EURUSD,M1: 9753093  ticks, 147480 bars generated. Environment synchronized in 0:00:02.610. 
Test passed in 0:00:19.062 (including ticks preprocessing 0:00:02.078).
2018.01.26 13:25:46.482 Core 1  EURUSD,M1: total time from login to stop testing 0:00:21.672 (including 0:00:02.610 for history data synchronization)
2018.01.26 13:25:46.482 Core 1  600 Mb memory used including 44 Mb of history data, 256 Mb of tick data