noneloquence

savitzkyGolay, KAMA, HP

Overview

This trading indicator integrates three distinct analytical tools: the Savitzky-Golay Filter, Kaufman Adaptive Moving Average (KAMA), and Hodrick-Prescott (HP) Filter. It is designed to provide a comprehensive analysis of market trends and potential trading signals.

Components

  • Hodrick-Prescott (HP) Filter

Purpose: Smooths out the price data to identify the underlying trend.

Parameters: Lambda: Controls the smoothness. Range: 50 to 1600.

Impact of Parameters:

  • Increasing Lambda: This makes the trend line more responsive to short-term market fluctuations, suitable for short-term analysis. A higher Lambda value decreases the degree of smoothing, making the trend line follow recent market movements more closely.
  • Decreasing Lambda: A lower Lambda value makes the trend line smoother and less responsive to short-term market fluctuations, ideal for longer-term trend analysis. Decreasing Lambda increases the degree of smoothing, thereby filtering out minor market movements and focusing more on the long-term trend.

  • Kaufman Adaptive Moving Average (KAMA):

Purpose: An adaptive moving average that adjusts to price volatility.

Parameters: Length, Fast Length, Slow Length: Define the sensitivity and adaptiveness of KAMA.

Impact of Parameters:

  • Adjusting Length affects the base period for efficiency ratio, altering the overall sensitivity.
  • Fast Length and Slow Length control the speed of KAMA’s adaptation. A smaller Fast Length makes KAMA more sensitive to price changes, while a larger Slow Length makes it less sensitive.

  • Savitzky-Golay Filter:

Purpose: Smooths the price data using polynomial regression.

Parameters: Window Size: Determines the size of the moving window (7, 9, 11, 15, 21).

Impact of Parameters:

  • A larger Window Size results in a smoother curve, which is more effective for identifying long-term trends but can delay reaction to recent market changes.
  • A smaller Window Size makes the curve more responsive to short-term price movements, suitable for short-term trading strategies.

General Impact of Parameters

Adjusting these parameters can significantly alter the signals generated by the indicator. Users should fine-tune these settings based on their trading style, the characteristics of the traded asset, and market conditions to optimize the indicator's performance.

Signal Logic

Buy Signal: The trend from the HP filter is below both the KAMA and the Savitzky-Golay SMA, and none of these indicators are flat.

Sell Signal: The trend from the HP filter is above both the KAMA and the Savitzky-Golay SMA, and none of these indicators are flat.

Usage

Due to the combination of smoothing algorithms and adaptability, this indicator is highly effective at identifying emerging trends for both initiating long and short positions.

IMPORTANT: Although the code and user settings incorporate measures to limit false signals due to lateral (sideways) movement, they do not completely eliminate such occurrences. Users are strongly advised to avoid signals that emerge during simultaneous lateral movements of all three indicators.

Despite the indicator's success in historical data analysis using its signals alone, it is highly recommended to use this code in combination with other indicators, patterns, and zones. This is particularly important for determining exit points from positions, which can significantly enhance trading results.

Limitations and Recommendations

The indicator has shown excellent performance on the weekly time frame (TF) with the following settings:

Savitzky-Golay (SG): 11
Hodrick-Prescott (HP): 100
Kaufman Adaptive Moving Average (KAMA): 20, 2, 30

For the monthly TF, the recommended settings are:

SG: 15
HP: 100
KAMA: 30, 2, 35

Note: The monthly TF is quite variable. With these settings, there may be fewer signals, but they tend to be more relevant for long-term investors. Based on a sample of 40 different stocks from various countries and sectors, most exhibited an average trade return in the thousands of percent.

It's important to note that while these settings have been successful in past performance, market conditions vary and past performance is not indicative of future results. Users are encouraged to experiment with these settings and adjust them according to their individual needs and market analysis.

As this is my first developed trading indicator, I am very open to and appreciative of any suggestions or comments. Your feedback is invaluable in helping me refine and improve this tool. Please feel free to share your experiences, insights, or any recommendations you may have.
Script de código abierto

Siguiendo el verdadero espíritu de TradingView, el autor de este script lo ha publicado en código abierto, para que los traders puedan entenderlo y verificarlo. ¡Un hurra por el autor! Puede utilizarlo de forma gratuita, aunque si vuelve a utilizar este código en una publicación, debe cumplir con lo establecido en las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.

Exención de responsabilidad

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.

¿Quiere utilizar este script en un gráfico?