Type/to search

Quantitative Trading Strategy Based on Price Crossover with SMA

Common strategy
Created: 2024-02-22 17:34:09
Last modified: 2 years ago
1
Follow
1802
Followers

img

Overview

The strategy is named "Quantitative Trading Strategy Based on Price Crossover with SMA". It mainly generates trading signals by calculating SMAs of different periods and tracking price crossover with SMAs. When price breaks SMA upwards, it triggers buy signal. When price breaks SMA downwards, it triggers sell signal.

Strategy Logic

The core logic of this strategy is to track price crossover with 21-day simple moving average (SMA). Meanwhile, it also calculates 50-day SMA and 200-day SMA to determine the general trend.

Specifically, the strategy requests close price within given date range, and calculates different SMAs based on input periods. If price breaks 21-day SMA upwards, it sets buy signal. If price breaks 21-day SMA downwards, it sets sell signal.

Along with calculating SMAs and determining crossovers, the strategy tracks current position as well. It enters position when buy signal triggers, and flattens position when sell signal triggers. In this way, it realizes automated trading system based on SMA crossover.

Advantage Analysis

The biggest advantage of this strategy is being simple and easy to understand and implement. SMA is a commonly used technical indicator and SMA crossover is one of the most common trading signals. This kind of indicator crossover strategies can be easily applied to different stocks and time range for automated trading.

Another advantage is that this strategy can be optimized by adjusting SMA parameters. For example, we can test different combinations of SMA periods to find the optimal one for specific stocks. Also, the strategy can be improved by adding other indicators for confirmation and optimization.

Risks and Solutions

The biggest risk of this strategy is that indicator-based strategies tend to generate excessive false signals. For instance, price may frequently crossover SMA during range-bound periods, resulting in unnecessary trades.

Common solutions include setting stop loss, tuning parameters, or adding filter conditions. For example, we can set maximum loss ratio to limit risk, adjust SMA periods to find more stable parameters, or use other indicators to filter some trading signals.

Optimization Directions

The strategy can be optimized in the following aspects:

  1. Test and select optimal SMA parameter combinations. Backtest different SMA lengths to find the best periods.

  2. Add other indicators for filterSignal confirmation, like RSI, MACD etc. This helps filter false signals.

  3. Incorporate stop loss logic. Set maximum tolerable loss or trailing stop to better control risks.

  4. Optimize entry timing. Consider entering around major breakouts rather than strictly following SMA crossover.

  5. Test composite strategies. Combine with other strategy types like trend following.

Conclusion

The strategy realizes automated trading with simple SMA crossover signals. The pros are being easy to understand and implement. The cons are excessive signals and prone to whipsaws. We can improve it by parameter tuning, adding filters, stop loss etc. The strategy provides us a basic framework. We can enrich it by incorporating more components.

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

//@version=5
strategy("Price Cross Above/Below SMA Strategy", shorttitle="Tressy Strat", overlay=true)

// Define start and end year inputs
Strategy parameters
Strategy parameters
Start Year
End Year
Start Month
End Month
SMA Length
50 SMA Length
200 SMA Length
Comment
All comments (0)
No data
No data
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)