Type/to search

Dual Moving Average Regression Trading Strategy

RPK
1
Follow
1802
Followers

img

Overview

This strategy uses two linear regression lines with different lengths as trading signals, combined with ATR for stop loss and partial profit taking. When the shorter-period linear regression line crosses above the longer-period linear regression line from below, it generates a long signal; conversely, when the shorter-period linear regression line crosses below the longer-period linear regression line from above, it generates a short signal. After opening a position, the strategy uses ATR as a trailing stop loss, while employing a partial profit-taking method to maximize profits.

Strategy Principles

  1. Calculate two linear regression lines with different periods (default 20 and 40) as trading signals
  2. When the shorter-period linear regression line crosses above the longer-period linear regression line, open a long position if there is no current position
  3. When the shorter-period linear regression line crosses below the longer-period linear regression line, open a short position if there is no current position
  4. Once a position is opened, use ATR to calculate the trailing stop loss price, and close all positions when the price reaches the stop loss level
  5. The strategy also employs a partial profit-taking method, calculating 16 different percentage take-profit levels (from 5% to 80%) based on the entry price, and closing a corresponding amount of positions at each take-profit level according to the input percentage
  6. Until all positions are closed

Advantage Analysis

  1. Using linear regression as a trend judgment and trading signal can better capture trends
  2. Combining two linear regressions with different periods forms a more reliable signal confirmation
  3. Using ATR as a stop loss can better control risks and keep in sync with price fluctuations
  4. The partial profit-taking method can obtain more profits when the trend continues, while also taking risk control into account
  5. The code is highly modularized with many input parameters, making the strategy highly customizable

Risk Analysis

  1. Linear regression signals may generate false signals, leading to losses
  2. Partial profit-taking may lead to longer holding periods, facing drawdown risks
  3. Improper parameter settings may lead to poor strategy performance
  4. In extreme market conditions, the strategy may face significant drawdowns

Optimization Directions

  1. Consider introducing more indicators or filtering conditions to improve signal accuracy, such as trend confirmation indicators, volatility indicators, etc.
  2. Optimize the position and strategy of take-profit and stop-loss, consider dynamic take-profit and stop-loss
  3. Optimize parameters to find the best parameter combination
  4. Add position management to adjust position size according to market volatility conditions

Summary

This dual moving average regression strategy combines trend-following and take-profit/stop-loss strategies, which can effectively capture trending markets while controlling drawdowns. However, the strategy may underperform in ranging markets and faces the problem of parameter optimization. Overall, this strategy is a typical representative of a trend-following strategy and can be used as a base strategy for optimization and improvement.

Source
Pine
/*backtest
start: 2023-05-24 00:00:00
end: 2024-05-23 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © fuatcakir9

//@version=5
Strategy parameters
Strategy parameters
Strategy Condition
regresyonUzunluk (Optional)
regresyonUzunlukUst (Optional)
ATR Carpan (Optional)
Değişen ATR Carpan (Optional)
İstenilen Istem Sayısı (Optional)
Settings of Strategy
Start Time of BackTest (Optional)
End Time of BackTest (Optional)
##### TP AND SL #####
TP1 Percent (Optional)
% TP1 Kapatma (Optional)
TP2 Percent (Optional)
% TP2 Kapatma (Optional)
TP3 Percent (Optional)
% TP3 Kapatma (Optional)
TP4 Percent (Optional)
% TP4 Kapatma (Optional)
TP5 Percent (Optional)
% TP5 Kapatma (Optional)
TP6 Percent (Optional)
% TP6 Kapatma (Optional)
TP7 Percent (Optional)
% TP7 Kapatma (Optional)
TP8 Percent (Optional)
% TP8 Kapatma (Optional)
TP9 Percent (Optional)
% TP9 Kapatma (Optional)
TP10 Percent (Optional)
% TP10 Kapatma (Optional)
TP11 Percent (Optional)
% TP11 Kapatma (Optional)
TP12 Percent (Optional)
% TP12 Kapatma (Optional)
TP13 Percent (Optional)
% TP13 Kapatma (Optional)
TP14 Percent (Optional)
% TP14 Kapatma (Optional)
TP15 Percent (Optional)
% TP15 Kapatma (Optional)
TP16 Percent (Optional)
% TP16 Kapatma (Optional)
Comment
All comments (0)
No data
No data
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)