Type/to search

Trend Following Strategy Based on Nadaraya-Watson Regression and ATR Channel

Cryptocurrency
Created: 2024-02-22 15:15:03
Last modified: 2 years ago
1
Follow
1781
Followers

img

Overview

This strategy is a trend following strategy that combines Nadaraya-Watson regression and ATR channel to identify trend direction and entry points. It goes long when price breaks through the lower rail and closes position when price breaks through the upper rail. A stop loss mechanism is also set.

Strategy Logic

Firstly, this strategy uses Nadaraya-Watson kernel regression to calculate two regression curves with different lags, and compares the crossover of the two curves to determine the trend direction. Specifically, it calculates the regression curves of h-period and h-lag-period respectively. When the h-lag-period curve crosses over the h-period curve, it indicates a long signal. When the h-lag-period curve crosses below the h-period curve, it indicates a short signal.

Secondly, this strategy uses ATR channel to determine entry points. The upper rail is the regression curve plus n-period ATR multiplier and the lower rail is the regression curve minus the n-period ATR multiplier. It goes long when price breaks through the lower rail and goes short when price breaks through the upper rail.

Finally, a stop loss mechanism is set. If the price stays below the entry price for stopLossBars consecutive bars, the position will be closed by stop loss.

Advantage Analysis

This strategy combines regression analysis and channel breakthrough, which can capture the trend direction and momentum relatively accurately. Compared with using single indicators like moving average to identify trends, this method reduces false signals and thus improves the stability of the strategy.

In addition, the ATR channel sets reasonable entry points, avoiding wrong entries around trend reversal points. The stop loss mechanism also effectively controls the single loss.

Therefore, this strategy has advantages like strong ability to identify trends, relatively accurate entries and exits, controllable single stop loss risk, etc.

Risk Analysis

The biggest risk of this strategy is that when price breaks through the ATR channel, it may just be making a reversal or consolidation, which leads to improper entry or quick stop loss after entry.

In addition, both the regression curves and ATR channels need some parameter optimization. Improper parameter settings may lead to poor regression analysis results or over-wide or over-narrow ATR ranges, which will affect the performance of the strategy.

Optimization Directions

We can consider combining other indicators to judge trend and reversal signals, such as VOLUME, MACD etc. to improve the stability and accuracy of the strategy.

The kernel function in the regression analysis can also be adjusted, such as trying Epanechnikov kernel, to see if better fitting effects can be obtained.

The ATR period and multiplier of the ATR channel also need repeated testing and optimization to find the best parameter combination.

Summary

This strategy combines the use of regression analysis and channel breakthrough to identify trend direction and strength, enters at reasonable points, and sets stop loss, thus realizing a stable trend following strategy. There is still a large room for further testing and improvement of this strategy.

Source
Pine
/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Custom Strategy with Stop Loss and EMA", overlay=true)

src = input(close, title='Source')
Strategy parameters
Strategy parameters
Source
Lookback Window
Relative Weighting
Start Regression at Bar
Lag
Stop Loss Bars
EMA Period
ATR Period
Multiplier
Comment
All comments (0)
No data
No data
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)