Recursive Zigzag Indicator

Recursive Zigzag Indicator
Recursive Zigzag Indicator

Zigzags are the basic building blocks of any pattern recognition algorithm. The reason why Trendoscope spends most of its time researching on enhancing Zigzag algorithms. Here is one of our latest attempts where adding any oscillator or custom indicator to zigzag pivots becomes an easy option to calculate divergence.

Link to the Indicator: Recursive Zigzag Indicator

Another Object-Oriented Implementation

Here is another outcome of the Object Oriented Zigzag and Pattern Ecosystem of Libraries.

We already have another implementation of recursive zigzag which makes use of an earlier library rzigzag. Here in this example, we make use of similar logic but leverage the new type and method-based Zigzag system libraries to derive the indicator.

Design Overview - Recursive Zigzag Indicator

Similar to Recursive Auto Pitchfork, here too the indicator code is around 50 lines. Whereas most of the heavy lifting is done by the libraries.

Recursive Zigzag - Design Overview
Recursive Zigzag - Design Overview

🎲 Base Libraries
Base libraries are those which does not have any dependency. They form basic structures which are later used in other libraries. These libraries need to be crafted carefully so that minimal updates are done later on. Any updates on these libraries will impact all the dependent libraries and scripts.

🎯 Drawing

  • DrawingTypes - Defines basic drawing types Point, Line, Label, Box, Linefill and related property types.
  • DrawingMethods - All the methods or functionality surrounding Basic types are defined here.


🎲 Layer 1 Libraries
These are the libraries which have a direct dependency on base libraries.
🎯 Zigzag

  • ZigzagTypes - Types required for defining Zigzag and Divergence
  • ZigzagMethods - Methods associated with Zigzag Type definitions.

Indicator Description - Recursive Zigzag

The indicator draws zigzags based on a given length. And then recursively derives next-level zigzags based on previous levels. As per the utility, the indicator is useful in several ways

  • Visualising price structure based on zigzag pivots - which in turn can help visualise patterns.
  • Ability to add any oscillator makes it easy to spot divergences with a choice of indicators.
  • Programmers can use the derived values to build complex algorithms such as automatic pattern recognition.

Settings of Recursive Zigzag

Settings are explained via tooltips. These are very straightforward and directly related to zigzag, oscillators and divergence.

Highlights of the settings are:

  • Chose either a dark or light theme to match the colours of the indicator to your background colour.
  • Select your preferred zigzag length and depth. The indicator uses the recursive algorithm. Hence, the more depth you chose, the more levels you see on the chart. Having said that, higher values can also cause runtime errors as the indicator is very much CPU and memory intensive.
  • Highlight one level of zigzag where you can also see indicator and oscillator values at pivot points.
  • Ability to choose a choice of indicators including those of external indicators. The display of oscillator values on pivots makes it easy to identify divergence.

Snapshots of settings are as shown below.

Recursive Zigzag - Settings Snapshot
Recursive Zigzag - Settings Snapshot

Alerts on Recursive Zigzag Indicator

Based on popular demand, we have introduced alerts on this indicator. Alerts can be set via input settings and using the alert widget.

Settings allow users to update their alert template. However, there is limited number of dynamic alert placeholders. These are:

  • {alertType} - based on the setting it is either the last pivot alert or the confirmed pivot alert.
  • {level} - This is the highlight level that is highlighted on the chart. Alerts are also fired for the same level of zigzag.
  • {pivot} - The complete detail of the pivot in JSON format. 

Alert settings can be seen below:

Alert settings for Recursive Zigzag Indicator
Alert settings for Recursive Zigzag Indicator

Comments