I couldn't understand the forum link you posted! and I would just drag the indicator onto the chart, but...
If you call this function from somewhere, it gives a print of the zz values, bars 0-9. - related to the attached image.
So at bar0 and bar5 are zz changes and you just work out the buffer number to extract the direction, where "buffer" is just the return value of iCustom(..)
It looks like buffer0 (x =0) is price, buffer1 (x=1)is down, buffer2(x=2 is up?
if(buffer0!=0&&buffer1!=0&&buffer2==0) // down etc etc
That gives you the bar, and from that you can work out price,time etc etc
string calc(){ string txt; int depth=12; for(int y=0;y<10;y++){ // last 10 bars txt=StringConcatenate(txt,"\nBar ",y," : "); for(int x=0;x<10;x++) // indicator buffers txt=StringConcatenate(txt,iCustom(_Symbol,_Period,"zigzag",depth,5,3,x,y)," "); } return txt; } /* Bar 0 : 1.04448 1.04448 0 0 0 0 0 0 0 0 Bar 1 : 0 0 0 0 0 0 0 0 0 0 Bar 2 : 0 0 0 0 0 0 0 0 0 0 Bar 3 : 0 0 0 0 0 0 0 0 0 0 Bar 4 : 0 0 0 0 0 0 0 0 0 0 Bar 5 : 1.04085 0 1.04085 0 0 0 0 0 0 0 Bar 6 : 0 0 0 0 0 0 0 0 0 0 Bar 7 : 0 0 0 0 0 0 0 0 0 0 Bar 8 : 0 0 0 0 0 0 0 0 0 0 Bar 9 : 0 0 0 0 0 0 0 0 0 0 */
You can use the following code:
//Before the main function double ZigZagArray[],zigzag[100]; int ZigZagHandle; void onTick(){ //Calling the function CheckForZigZag(); //Print as many as you want. for example 2 value here Print(zigzag[0],zigzag[1]); } void CheckForZigZag() { ZigZagHandle=iCustom(_Symbol,PERIOD_M15,"Examples\\ZigZag",12,5,3); ArraySetAsSeries(ZigZagArray,true); CopyBuffer(ZigZagHandle,0,0,100,ZigZagArray); int zigzag_counter=0; for(int i=0; i<100; i++) { if(ZigZagArray[i]!=0.0) { zigzag[zigzag_counter]=ZigZagArray[i]; zigzag_counter++; } } }

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
In my EA below, I have programmatically drawn the default ZigZag indicator. I would like to access the last two fixed values of the ZigZag. How can I achieve this?
I saw this post (https://www.mql5.com/en/forum/131897)but I'm not certain how to apply this to arrive at my solution