Tags:

The Dual SMA Crossover strategy generates trading signals by calculating the crossover of two SMA lines with different parameter settings. When the faster SMA line crosses above the slower SMA line, a buy signal is generated. When the slower SMA line crosses below the faster SMA line, a sell signal is generated. The strategy uses two sets of SMA parameters at the same time, one set to determine entry points, and the other to determine exit points.

This strategy uses two sets of SMA parameters, `smaB1`

, `smaB2`

for buy signals, and `smaS1`

, `smaS2`

for sell signals, representing slower and faster moving averages respectively. When `smaB1`

crosses above `smaB2`

, a buy signal is generated. When `smaS2`

crosses below `smaS1`

, a sell signal is generated. This allows flexible adjustment of entry and exit conditions to adapt to changing market environments.

Specifically, this strategy monitors the crossover situations between the two SMA lines calculated from the close price to determine the timing of buying and selling. When the faster SMA line crosses above the slower SMA line, it is judged that the price trend is upward, so go long at this time. And when the slower SMA line crosses below the faster SMA line, the price trend turns downward, so exit long positions.

The main advantages of this strategy are:

- Using a dual moving average crossover system allows flexible tuning of entry and exit criteria to adapt to market changes
- The SMA lines themselves can filter out some noise and generate more reliable trading signals
- Customizable SMA parameter combinations allow parameter optimization for different products

There are also some risks associated with this strategy:

- SMA crossover signals may lag and fail to generate timely signals around turning points
- Improper selection of SMA parameters can lead to too many false signals
- Signals generated in volatile market conditions may not work well

To control the above risks, methods like SMA parameter optimization, dynamic stop loss to lock in profits, etc. can be used to improve the strategy.

Some optimization directions for this strategy:

- Test more SMA parameter combinations to find the optimal parameters
- Add volume confirmation to avoid wrong signals during violent price fluctuations
- Combine other indicators (e.g. MACD, RSI) to filter SMA crossover signals
- Add stop loss strategies to lock in profits and reduce losses

The SMA Crossover strategy generates simple and effective trading signals by calculating the crossover situations between two SMA lines. The flexibility to adjust parameters makes this strategy adaptable to different products, and it is a commonly used trend following strategy. Further improvements can be made to this strategy through parameter optimization, signal filtering etc. to generate more reliable signals.

/*backtest start: 2023-11-15 00:00:00 end: 2023-11-22 00:00:00 period: 5m basePeriod: 1m 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/ // © melihtuna //@version=4 strategy("SMA Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=10000, currency=currency.USD, commission_value=0.1, commission_type=strategy.commission.percent) smaB1 = input(title="smaB1",defval=377) smaB2 = input(title="smaB2",defval=200) smaS1 = input(title="smaS1",defval=377) smaS2 = input(title="smaS2",defval=200) smawidth = 2 plot(sma(close, smaB1), color = #EFB819, linewidth=smawidth, title='smaB1') plot(sma(close, smaB2), color = #FF23FD, linewidth=smawidth, title='smaB2') plot(sma(close, smaS1), color = #000000, linewidth=smawidth, title='smaS1') plot(sma(close, smaS2), color = #c48dba, linewidth=smawidth, title='smaS2') // === INPUT BACKTEST RANGE === FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12) FromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31) FromYear = input(defval = 2020, title = "From Year", minval = 2017) ToMonth = input(defval = 1, title = "To Month", minval = 1, maxval = 12) ToDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31) ToYear = input(defval = 9999, title = "To Year", minval = 2017) // === FUNCTION EXAMPLE === start = timestamp(FromYear, FromMonth, FromDay, 00, 00) finish = timestamp(ToYear, ToMonth, ToDay, 23, 59) window() => time >= start and time <= finish ? true : false longCondition = crossover(sma(close, smaB1),sma(close, smaB2)) if (window() and longCondition) strategy.entry("BUY", strategy.long) shortCondition = crossover(sma(close, smaS2),sma(close, smaS1)) if (window() and shortCondition) strategy.entry("SELL", strategy.short)

- Combo Momentum Reversal Dual-Rail Matching Strategy
- Ichimoku Cloud Quant Strategy
- Adaptive Take Profit and Stop Loss Strategy Based on Dual Time Frames and Momentum Indicators
- Multi-Period RSI Grid Trading Strategy
- Dual Exponential Moving Average Crossover Strategy
- Trend Tracking Moving Average RSI Strategy
- Monthly Close Price and Moving Average Crossover Strategy
- Bollinger Bands Breakout short-term trend following Strategy
- Buying dips with take profit and stop loss
- RSI Axial Moving Average Crossover Strategy
- Dual EMA and RSI Combination Strategy
- Speculation Gulf : Trend Follow Strategy Based on SAR
- ORIGINAL PRIMITIVE TREND TRACKING STRATEGY BASED ON MOVING AVERAGE
- The Bollinger Bands Stop Loss Strategy
- Trend Tracking Strategy Based on Multi-indicator
- Multiple Moving Average Dynamic Trend Strategy
- Price-based Stop Loss and Take Profit Strategy
- Timeframe Power Trading Strategy
- Bi-Directional Trend Tracking Moving Average Crossover Strategy
- Personalized Momentum Trading Strategy