Type/to search

Price Crossing Moving Average Trend Following Strategy

Common strategy
Created: 2024-01-26 15:18:29
Last modified: 3 years ago
1
Follow
1802
Followers

img

Overview

This strategy generates buy and sell signals based on the crossing of price with a moving average. It provides various types of moving averages and a tolerance parameter to filter false breakouts. The strategy aims to capture turning points in price trends for trend following.

Strategy Logic

The strategy calculates a length N moving average based on the closing price. Typical moving average types include Simple Moving Average (SMA), Exponential Moving Average (EMA), Weighted Moving Average (WMA) etc. Then a tolerance level is set, e.g. 5%, and upper band (1.05 times moving average) and lower band (0.95 times moving average) are calculated. When closing price crosses above upper band, a buy signal is generated. When closing price crosses below lower band, a sell signal is generated. This helps filter some false breakouts. Also, a Boolean parameter "Short Only" is provided. When enabled, only sell signals are generated for shorting the market.

Advantages

  • Effectively follows price trends using moving average's trend following characteristics
  • Provides various moving average types for flexible combinations
  • Tolerance parameter helps filter false breakouts and avoid unnecessary trades
  • Can go short only, suitable for catching downward trends

Risks

  • Moving averages have lagging effect, may miss price turning points
  • Not suitable for range-bound market environments
  • Improper tolerance parameter settings may filter valid signals
  • Going short has higher risks, need prudent operations

Optimization Directions

  • Optimize moving average type and length parameters
  • Test different tolerance parameter settings
  • Add other indicators to filter signals
  • Employ position sizing strategies

Conclusion

Overall this is a typical trend following strategy. It uses the relationship between price and moving average to determine trends, with some flexibility. Through parameter optimization and proper signal filtering, it can become a decent quant strategy. But controlling downside risks when shorting is important to avoid excessive losses.

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

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RafaelPiccolo

//@version=4
Strategy parameters
Strategy parameters
MA Type
Length
Source
Tolerance (%)
Short only
Comment
All comments (0)
No data
No data
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)