Multi Zigzag and Multi Oscillator Divergence

Don't want to rely on a single oscillator or zigzag periods, this indicator provides a bird's view of combined divergence status for multiple zigzag levels and multiple oscillators.

Link to the Indicator: Multi Zigzag and Multi Oscillator Divergence

Concept of Multi Zigzag Oscillator Divergence Indicator

This table is intended to give you a snapshot of how prices and oscillators are moving along with zigzag pivots.

This is done along the same lines as Zigzag-Trend-Divergence-Detector
But, here are the differences

  • Table shows multiple oscillator movements at the same time instead of one selected oscillator
  • Divergence is calculated as per Zigzag based Supertrend for all levels of zigzag. Original implementation of zigzag supertrend is here: ZigZag-Supertrend
  • This system also uses multiple zigzags instead of just one.

Process of Defining the Divergence Indicator

  • Derive multiple zigzags - Code is taken from Multi-ZigZag
  • Along with zigzags, calculate different oscillators and attach them to a zigzag pivot.
  • Calculate directions of zigzag pivots and corresponding oscillators.
  • Plot everything in the table on the last bar.

Table Display components

The table contains the following data:

Multi Zigzag Multi Oscillator Divergence
Multi Zigzag Multi Oscillator Divergence

Directional legends:

  • ⇈ - Higher High (Green)
  • ⇊ - Lower Low (Red)
  • ⭡- Lower High (Orange)
  • ⭣ - Higher Low (Lime)

Sentiment Calculation:

The sentiment is calculated based on the divergence formula tabulated here.

Divergence Sentiment Calculation CheatSheet
Divergence Sentiment Calculation CheatSheet

Settings for Multi Zigzag and Multi Oscillator Indicator

  • Source: Default is "Close" price. If Unchecked - uses high/low data for calculating pivots. Can also use external input such as OBV
  • Stats: Gives the option to select the output depth (History) and lets you choose text size and table position.
  • Oscillators: Oscillator length is derived by multiplying the multiplier by the zigzag length. For example, for zigzag 5, with 4 as the multiplier, all oscillators are calculated with length 20. But, the same for Zigzag 8 will be 32 and so on.
  • Available oscillators :
    • CCI - Commodity Channel Index
    • CMO - Chande Momentum Oscillator
    • COG - Center Of Gravity
    • MFI - Money Flow Index (Shows only if the volume is present)
    • ROC - Rate Of Change
    • RSI - Relative Strength Index
    • WPR - William Percent R
    • BB - Bollinger Percent B

Note

  • There are 8 oscillators and each zigzag has a different length. This means, there are 32 combinations of oscillators. The first challenge was generating these values without creating lots of static initialization. Also, note, if the functions are not called on each bar, then they will not yield the correct result. This is achieved through the initializer function which runs on every bar and stores the oscillator values in an array that emulates a multi-dimensional array oscillator X zigzag length.
  • Next challenge was getting these values within the function when we need them. While doing so I realized that values stored in an array also have historical series and calling array.get() will actually get you the entire series and not just the value. This is an important takeaway for me and this can be used for further complex implementations.

 

Comments