Libraries: High-performance iTimeSeries for time-sensitive applications

 

High-performance iTimeSeries for time-sensitive applications:

This time-series library brings lightning-fast timeseries access to MQL5 for time-sensitive applications while implementing the familiar methods of MQL4, e.g. iBarShift.

Example:

#include <itimeseries_nicholishen.mqh>
//--- global declaration of iTimeSeries object
CiTimeSeries iBar;
int OnInit()
{
//--- initialization phase
   iBar.Init(  NULL,
               PERIOD_CURRENT,
               false  // bool auto-refresh              
               );
//---
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
//---
   if(hot_path_operations)
   {  //example
      index = iBar.Shift(time);
   }
   else if(maintenance_path_operations)
   {
      iBar.Refresh();   
   }
}

Author: nicholishen

 

Nice work.

However your comparison of iBarshift performance is a bit tricky, the purpose of a 100,000 iterations loop is to get an averaged and usable time value (in ms). Your iBarShift() need initialization of an object and this initialization is not counted in your loop but outside.  Anyway, for sure keeping all values in memory is faster than calculating them each time.

 

BTW, iBarShiftFast mentioned in reference benchmarks can be improved to be as simple as:

(Bars(symbol, timeframe, time, D'2100.01.01') - 1)

and may be even inlined. The improvement is to eliminate SeriesInfoInteger completely and use a constant date in distant future.

 
Alain Verleyen:

Nice work.

However your comparison of iBarshift performance is a bit tricky, the purpose of a 100,000 iterations loop is to get an averaged and usable time value (in ms). Your iBarShift() need initialization of an object and this initialization is not counted in your loop but outside.  Anyway, for sure keeping all values in memory is faster than calculating them each time.


Thanks! :) 


That's a great point and yes the "performance mode" demo does initialize out-side of the loop, however, the direct call to iBarShift in the second benchmark is instantiating an object which is why it's taking longer to complete the 100,000 cycles... because it has to instantiate and initialize a static global object before calling back to it for data - so the second test is a fair comparison. The "performance mode" is also a fair comparison if you consider it as data access only within a hot-path operation. 

BTW, I just ran some tests and want to specify again for anyone reading this: This method is only faster if you plan to separate data refreshing & data calling into separate pathways OR you call any combination of time-series function calls more than an aggregate total of 300 times per bar. So in other words the ~300 iteration mark is the break-even point. If you don't call more than 300 times per bar and you aren't using a "hot-path" then you're probably better off using other methods. 

 

Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий

Библиотеки: Высокопроизводительная библиотека iTimeSeries

fxsaber, 2017.05.25 13:23

iBarShift benchmark based on 100000 runs.
=======================================================
iBarShift(Alain Verleyen) for 2017.04.11 19:56:37 is 45723 in 338.868 milliseconds.
-------------------------------------------------------------
iBarShift3 for 2017.04.11 19:56:37 is 45723 in 0.492 milliseconds.
-------------------------------------------------------------
iBarShift(direct function call) for 2017.04.11 19:56:37 is 45723 in 38.712 milliseconds.
-------------------------------------------------------------
iBar.Shift(performance mode) for 2017.04.11 19:56:37 is 45723 in 3.403 milliseconds.
-------------------------------------------------------------
Reason: