ezyquant.indicators.zigzag.peak_valley_pivots_candlestick#
- ezyquant.indicators.zigzag.peak_valley_pivots_candlestick(close, high, low, up_thresh, down_thresh)#
Finds the peaks and valleys of a series of HLC (open is not necessary). TR: This is modified peak_valley_pivots function in order to find peaks and valleys for OHLC. :param close: :type close: This is series with closes prices. :param high: :type high: This is series with highs prices. :param low: :type low: This is series with lows prices. :param up_thresh: :type up_thresh: The minimum relative change necessary to define a peak. :param down_thesh: :type down_thesh: The minimum relative change necessary to define a valley.
- Returns:
an array with 0 indicating no pivot and -1 and 1 indicating valley and peak
respectively
Using Pandas
————
For the most part, close, high and low may be a pandas series. However, the index must
either be [0,n) or a DateTimeIndex. Why? This function does X[t] to access
each element where t is in [0,n).
The First and Last Elements
—————————
The first and last elements are guaranteed to be annotated as peak or
valley even if the segments formed do not have the necessary relative
changes. This is a tradeoff between technical correctness and the
propensity to make mistakes in data analysis. The possible mistake is
ignoring data outside the fully realized segments, which may bias analysis.