Skip to content

ZigZag Indicator Non-Deterministic Behavior #172

@BlackBoxTradingGroup

Description

@BlackBoxTradingGroup

I found it incredibly confusing that the output_values array can be modified in place by the indicator.

This diabolical behavior could lead to catastrophic live trading performance since batch vs iterative input yield different results.

The behavior that I expected was that pivots would be added to the output_values array only AFTER they are confirmed to be pivots, given the min_trend_length.

It makes sense that users may want to see potential pivots in real time as they form, but the API doesn't expose any method to see once a pivot is confirmed.

Honestly, the entire API is not good for iterative input. When you add a new candle, the API should return a new Pivot or None. That would be the most intuitive approach. Not having these features has forced me to write smelly code like this:

    prev_len = len(self._zig_zag)
    self._zig_zag.add(ohlc)
    if (len(self._zig_zag) > prev_len) and prev_len > 1:
        new_swing = self._zig_zag[-2]  # get pivot only after it is confirmed
        print(new_swing, '@', str(ohlc.time))

I recommend that even if you don't change the indicator behavior that you at a minimum add some notes and warnings to the documentation about how to use the indicator. It took me an hour of debugging to figure out what was going on.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions