This script combines kernel regression, envelope calculations, and the Stochastic Momentum Index (SMI) to generate trading signals. It uses a Nadaraya-Watson estimator with a Rational Quadratic kernel to model price trends, constructs an envelope around the estimated trend using Average True Range (ATR), and utilizes the SMI to identify potential overbought/oversold conditions for entry and exit points.
Strategy Logic:
Kernel Regression:
The script employs the Nadaraya-Watson estimator, a non-parametric regression technique, to estimate the underlying trend of the price. It utilizes the Rational Quadratic kernel function, which allows for flexible weighting of past data points based on their distance in time. The h parameter controls the lookback window (number of bars used for estimation), alpha determines the relative weighting of time frames, and x_0 sets the starting bar for regression.
Envelope Calculation:
An envelope is created around the estimated trend (yhat_close) to define potential support and resistance levels. The envelope's boundaries are calculated using a multiple of the ATR, which measures market volatility. nearFactor and farFactor control the width of the envelope, creating near and far boundaries.
Smoothing:
The script includes an option to smooth the SMA output using various moving average types (SMA, EMA, SMMA, WMA, VWMA). This smoothing helps to filter out noise and provide a clearer trend signal.
Stochastic Momentum Index (SMI):
The SMI is used as a momentum oscillator to identify potential overbought and oversold conditions. It measures the distance of the current close relative to the midpoint of the high-low range over a specified period. Crossovers between the SMI and its EMA signal potential trend reversals.
Entry and Exit Conditions:
Long Entry: A long position is entered when the smoothing line is below the lower far boundary of the envelope, the SMI crosses above its EMA, and the SMI is below -50 (indicating oversold conditions). Short Entry: A short position is entered when the smoothing line is above the upper far boundary of the envelope, the SMI crosses below its EMA, and the SMI is above 50 (indicating overbought conditions). Long Exit: A long position is closed when the price crosses above the upper far boundary. Short Exit: A short position is closed when the price crosses below the lower far boundary. Stop Loss: A stop loss is set at a user-defined number of ticks below the entry price for long positions and above the entry price for short positions.
Customization:
The script offers extensive customization options, including:
Kernel parameters (lookback window, relative weighting, starting bar) Envelope parameters (ATR length, near/far factors) Smoothing method and length SMI parameters (lengths for %K, %D, and EMA) Timeframe for SMI calculation Colors for plots and fills Stop loss level
Disclaimer: This script is for educational purposes and should not be considered financial advice. Backtesting and thorough analysis are recommended before using this strategy in live trading. The effectiveness of the strategy may vary depending on market conditions and the chosen parameters.
Siguiendo fielmente el espíritu de TradingView, el autor de este script lo ha publicado en código abierto, permitiendo que otros traders puedan entenderlo y verificarlo. ¡Olé por el autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la reutilización de este código en la publicación se rige por las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.
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.