Nicolas

ZigZag Average

Category: Indicators By: Nicolas Created: May 30, 2018, 7:54 PM
May 30, 2018, 7:54 PM
Indicators
13 Comments
ZigZag Average

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.

//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)

 

Download
Filename: PRC_ZigZag-Average.itf
Downloads: 501
Nicolas
Nicolas Legend
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

rama
6 years ago
#

I noticed it changes as time progress, I am 7 as the average, how many period it wont change much?

rama
6 years ago
#

I want to use this indicator in trading system, it says zig zag is obsolete and not supported

Nicolas
6 years ago
#

Right, due to its repainting behavior, the zigzag is not allowed in automated trading with real transaction.

lukapex
7 years ago
#

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!

Nicolas
7 years ago
#

This is an SMA = Simple Moving Average

Karthick S
8 years ago
#

Hi Nicolas, Can you please share MT4 version of this? Cheers

Nicolas
8 years ago
#

No. This website is only dedicated to ProRealTime programming :)

eckaw
8 years ago
#

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?

Nicolas
8 years ago
#

Yes, this could be easily programmed with the assisted creation tool.

Glen Marquis
8 years ago
#

Nice. I like this, are the graphics as pretty when used with market entries?

Nicolas
8 years ago
#

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.

Stenozar
8 years ago
#

Hi Forexchekup! on which instruments do you use it?

Forexcheckup
8 years ago
#

Thank you vey much for your swift response, hope others find it useful!

ProRealCode ProRealCode
Loading...