The basic algorithm for this indicator is Zig Zag indicator. Each time a new peak or trough is found, the averaged value are inverted:
- if last ZigZag point is a peak: the moving average is calculated with Highs
- if last ZigZag point is a trough: the moving average is calculated with Lows
This indicator was coded by a request in the English indicators forum.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
//PRC_ZigZag Average | indicator //30.05.2018 //Nicolas @ www.prorealcode.com //Sharing ProRealTime knowledge //--- settings Percentage = 1 mmPeriod = 30 //--- end of settings peak = ZigZag[Percentage](high) trough = ZigZag[Percentage](low) if peak<peak[1] and peak[1]>peak[2] then last=1 endif if trough>trough[1] and trough[1]<trough[2] then last=-1 endif if last>0 then mm=average[mmPeriod](high) else mm=average[mmPeriod](low) endif if mm>mm[1] then r=0 g=128 b=196 else r=255 g=0 b=0 endif return mm coloured(r,g,b) style(line,2) |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :
Filename : download the ITF files
How to import ITF files into ProRealTime platform?
PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Thank you vey much for your swift response, hope others find it useful!
Hi Forexchekup! on which instruments do you use it?
Nice. I like this, are the graphics as pretty when used with market entries?
Because of its natural behavior, the zigzag makes the indicator more pretty in the past as it is in real time.. Using another kind of peaks and troughs detection should make it more accurate and valuable for trading.
I’m trying to make a strategy based on EMA crosses over the ZigZag Average. Is there a way to generate these signals and copy them onto “myIndicator2” and simply print the signals (for example: +1; -1) ? If this is possible, maybe the strategy can be built with myIndicator2, then overcoming the ZigZag issue with auto trading. Any thoughts?
Yes, this could be easily programmed with the assisted creation tool.
Hi Nicolas,
Can you please share MT4 version of this?
Cheers
No. This website is only dedicated to ProRealTime programming 🙂
Hello, can you please tell me what is the average in mm=average[mmPeriod] ? How is that calculated,based on what?Something like ema,sma or? Thank You!
This is an SMA = Simple Moving Average
I want to use this indicator in trading system, it says zig zag is obsolete and not supported
Right, due to its repainting behavior, the zigzag is not allowed in automated trading with real transaction.
I noticed it changes as time progress, I am 7 as the average, how many period it wont change much?