Dual Moving Average Regression Trading Strategy
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
- Calculate two linear regression lines with different periods (default 20 and 40) as trading signals
- 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
- 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
- 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
- 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
- Until all positions are closed
Advantage Analysis
- Using linear regression as a trend judgment and trading signal can better capture trends
- Combining two linear regressions with different periods forms a more reliable signal confirmation
- Using ATR as a stop loss can better control risks and keep in sync with price fluctuations
- The partial profit-taking method can obtain more profits when the trend continues, while also taking risk control into account
- The code is highly modularized with many input parameters, making the strategy highly customizable
Risk Analysis
- Linear regression signals may generate false signals, leading to losses
- Partial profit-taking may lead to longer holding periods, facing drawdown risks
- Improper parameter settings may lead to poor strategy performance
- In extreme market conditions, the strategy may face significant drawdowns
Optimization Directions
- Consider introducing more indicators or filtering conditions to improve signal accuracy, such as trend confirmation indicators, volatility indicators, etc.
- Optimize the position and strategy of take-profit and stop-loss, consider dynamic take-profit and stop-loss
- Optimize parameters to find the best parameter combination
- 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.
- 1

