An array of numerical price values representing the time series.
An array of corresponding date strings for each price value.
The threshold percentage that determines whether a swing high or swing low is significant.
result: A Swings struct containing: - swing_high_values: An array of detected swing highs. - swing_high_dates: Corresponding dates for swing highs. - swing_low_values: An array of detected swing lows. - swing_low_dates: Corresponding dates for swing lows.
Notes: - The function initializes the first price as the starting pivot and iterates through the time series to detect swings. - A swing high is identified when price movement shifts from increasing to decreasing beyond the threshold percentage. - A swing low is identified when price movement shifts from decreasing to increasing beyond the threshold percentage. - If no prior swing highs/lows exist, the first detected high or low is stored. - If a new detected swing point deviates from the last recorded swing high/low by more than the swingPercentage, it is added to the result. - The function assumes prices_IN and dates_IN have the same length. - Swing analysis is commonly used in technical analysis to identify market trends, support, and resistance levels.
Summary: Identifies swing highs and swing lows in a time series of price data based on a given swing percentage threshold. The function detects turning points where price movement changes direction beyond the specified percentage.