I have used iCustom() to call ZigZag indicator but get some problem,
In OnInit() function the code like this:
the m_handle_indicator get 0, means it is created successful...
but when I try to read the buffer:
In OnTick() function
it return error message:"error BarCalculate = -1"
Something wrong in my code???
You have to let some times to the indicator to be calculated, see the example in the documentation :
for(i=0;i<100;i++) { if(BarsCalculated(m_handle_indicator)>0) break; Sleep(50); }
You have to let some times to the indicator to be calculated, see the example in the documentation :
I have add the code as you said ...but nothing change. It still return -1 by BarCalculated()
It works for me :
int m_handle_indicator=INVALID_HANDLE; if(m_handle_indicator==INVALID_HANDLE) if((m_handle_indicator=iCustom(NULL,PERIOD_CURRENT,"Examples\\ZigZag",12,5,3))==INVALID_HANDLE) { printf("Error creating iCustom indicator"); return; } Print("Handle :",m_handle_indicator); for(int i=0;i<100;i++) { if(BarsCalculated(m_handle_indicator)>0) break; Sleep(50); } printf("BarCalculate = %d ",BarsCalculated(m_handle_indicator));
results :
2013.07.03 13:50:40 test (EURUSD,H1) BarCalculate = 10183
2013.07.03 13:50:40 test (EURUSD,H1) Handle :10
It works for me :
results :
2013.07.03 13:50:40 test (EURUSD,H1) BarCalculate = 10183
2013.07.03 13:50:40 test (EURUSD,H1) Handle :10
i think something wrong in this line:
if((m_handle_indicator=iCustom(NULL,PERIOD_CURRENT,"Examples\\ZigZag",InpDepth,InpDeviation,InpBackstep))==INVALID_HANDLE)
if i change"Examples\\ZigZag" to anything else(i means even to give a wrong name) ,it also return 0 .
I have found the bug finally :
Init the m_handle_indicator first ,and all the things works properly.
m_handle_indicator=INVALID_HANDLE;
thanks all.

- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have used iCustom() to call ZigZag indicator but get some problem,
In OnInit() function the code like this:
the m_handle_indicator get 0, means it is created successful...
but when I try to read the buffer:
In OnTick() function
it return error message:"error BarCalculate = -1"
Something wrong in my code???