Discussion of article "Implementing indicator calculations into an Expert Advisor code"

To add comments, please log in or register
MetaQuotes
Moderator
224440
MetaQuotes  

New article Implementing indicator calculations into an Expert Advisor code has been published:

The reasons for moving an indicator code to an Expert Advisor may vary. How to assess the pros and cons of this approach? The article describes implementing an indicator code into an EA. Several experiments are conducted to assess the speed of the EA's operation.

Below is what we are going to do to relocate the indicator calculations to an EA.

  1. Arrange the operation of indicator buffers. To do this, create the CArrayBuffer class with methods for data storage and convenient access. Later, create the array of such classes by the number of buffers in the indicator.
  2. Relocate the indicator calculation part from the OnCalculate function to the Calculate function of our class.
  3. The indicator receives access to timeseries from the OnCalculate function parameters (unlike the EA functions). Therefore, let's arrange the download of necessary timeseries in the LoadHistory function.
  4. To unify access to the recalculated indicator data, let's create the CopyBuffer function with all necessary parameters in the CIndicator class. 

All the work can be visually summarized as follows.

Author: Dmitriy Gizlyk

Fab
33
Fab  
MetaQuotes:

New article Implementing indicator calculations into an Expert Advisor code has been published:

Author: Dmitriy Gizlyk

Blast from the past here.

Very interesting article indeed! Sound and nice concept... but I fear there is a mistake in the distributed software, and it is not good to leave errors around.


Method GetData. Distributed code is:

double CIndicator::GetData(const uint buffer_num,const uint shift)
  {
   if(!Calculate())
      return EMPTY_VALUE;
//---
   if((int)buffer_num>=m_buffers)
      return EMPTY_VALUE;
//---
   return ar_IndBuffers[buffer_num].At(m_data_len-shift);
  }

Corrected code should be:

double CIndicator::GetData(const uint buffer_num,const uint shift)
  {
   if(!Calculate())
      return EMPTY_VALUE;
//---
   if((int)buffer_num>=m_buffers)
      return EMPTY_VALUE;
//---
   return ar_IndBuffers[buffer_num].At(m_data_len-shift - 1);
  }

Array index starts from 0 and last element has index (m_data_len - 1) instead of m_data_len, isn't it?

To add comments, please log in or register