Example of how to use CiCustom
After some in depth debugging, I realized I've been using CiCustom wrong. The documentation is unclear but by implementation it is now apparent that CiCustom was intended to derive subclasses. Making custom indicator classes is very easy of you use the following pattern.
- Inherit CiCustom
- Make a custom Create method that's applicable to the indicator setup.
- Override the Initialize method.
Can you gently post the relative two buffers indicator code so I can do a test with your solution?
Thank you in advance for everyone can help me to solve this problem.
//the class class CiOverlap : public CiCustom { private: double m_up_buffer[]; double m_body_buffer[]; double m_down_buffer[]; ... //the indicator double UpBuffer[]; double BodyBuffer[]; double DownBuffer[]; ... int OnInit(){ ... if(!SetIndexBuffer(0, UpBuffer, INDICATOR_DATA)) { warning here }; if(!SetIndexBuffer(1, BodyBuffer,INDICATOR_DATA)) { warning here }; if(!SetIndexBuffer(2, DownBuffer, INDICATOR_DATA)){ warning here }; --> as expected is always ok } int OnCalculate(...){ --> some computations here msg="UpBuffer.size = " + IntegerToString(ArraySize(UpBuffer));__Log__(Debug,msg); --> the same for other buffers.. --> arrays are ALWAYS EQUALLY SIZED with their right computed values --> mean no problem inside the indicator } nb. this CiOverlap class code is triggered by CExpert::Processing method (on my CExpert derived class) ... buffer_index = 0; if (CIndicator::GetData(0, items_to_be_copied, buffer_index, _buf) > 0) { --> IS ALWAYS OK! } buffer_index = 1; if (CIndicator::GetData(0, items_to_be_copied, buffer_index, _buf) > 0) { --> never enter here } else{ --> IS ALWAYS (-1) } --> the same for the other buffers
I try different approach :
up_total =::CopyBuffer(m_handle, 0, 0, items,m_up_buffer); --> ALWAYS RIGHT this.Refresh(); body_total =::CopyBuffer(m_handle, 1, 0, items,m_body_buffer); --> IS ALWAYS (-1) down_total =::CopyBuffer(m_handle, 2, 0, items,m_down_buffer); --> IS ALWAYS (-1) OR: ((CIndicatorBuffer*)At(buffer_index)).Refresh(m_handle,buffer_index); if (this.GetData(0, items, buffer_index, _buf) > 0) --> ALWAYS OK for buffer_index = 0 --> ALWAYS(-1) with buffer_index > 0
UPDATE:
I fixed my bug, the problem arise because I define more than one buffer with INDICATOR_DATA flag and the SL silently accept only one (the first). So all the succedings access (via CopyBuffer/GetData) to that buffers give always -1.
I really thanks everyone here for that great community and extremely professional articles.
my work can now move forward again!

- 2020.03.27
- www.mql5.com
Hello @nicholish en, thank you for this article.
could you provide an example of the mq5 file that is calling this class ?
I am also wondering how to pass the parameters source mq5 input parameters to the alexstal_zigzagprof indicator once the program is running (Do I need to change to extern instead of input or is there another way?).
Thank you ! :)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
After some in depth debugging, I realized I've been using CiCustom wrong. The documentation is unclear but by implementation it is now apparent that CiCustom was intended to derive subclasses. Making custom indicator classes is very easy of you use the following pattern.