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?
rf, section Working with custom indicators of https://www.mql5.com/en/articles/261

- www.mql5.com
thanks alot
Very nice concept , but if I want to write a price action indicator with multiple prices (high,low,close,open)which calculates indicator value based on i.e difference of high and low there is a problem of having only one array of data (m_source_data in CIndicator class),is there a way to work around this or do you suggest to modify the CIndicator class and make the m_source_data an array of (mqlRates or CArrayBuffer ,...)?
thanks alot
Very nice concept , but if I want to write a price action indicator with multiple prices (high,low,close,open)which calculates indicator value based on i.e difference of high and low there is a problem of having only one array of data (m_source_data in CIndicator class),is there a way to work around this or do you suggest to modify the CIndicator class and make the m_source_data an array of (mqlRates or CArrayBuffer ,...)?
Yes, you can modify CIndicator to create m_source_data as array of MqlRates. I recommend MqlRates because other ways you will need some actions to synchronize data in different arrays.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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.
All the work can be visually summarized as follows.
Author: Dmitriy Gizlyk