This strategy uses the crossover of two moving averages with different periods to generate trading signals. It belongs to trend following strategies. The strategy captures trending opportunities by using signals when a shorter period MA crosses a longer period MA.
The strategy uses a 9-period short term MA (SMA) and a 50-period long term MA (LMA). When the SMA crosses above the LMA, a buy signal is generated. When the SMA crosses below the LMA, a sell signal is generated.
The strategy also incorporates the RSI indicator to gauge the strength of the trend. Trading signals are only generated when RSI is above a threshold (default 55). This avoids incorrect signals when RSI is in overbought zones.
The strategy trades 30% of total capital each time, with only one position open at a time. 0.1% commission is accounted for.
Risks can be reduced via parameter optimization, using other indicators, strict capital management, and stop loss.
The strategy captures trending opportunities using simple MA crossover system. Default parameters are optimized with steady returns, suitable for algorithmic trading. Further improvements can be made by adding other indicators, optimizing parameters, and implementing stop loss. Overall, it is an effective trend following strategy for trending markets using crossover signals.
/*backtest start: 2023-09-16 00:00:00 end: 2023-10-16 00:00:00 period: 2h 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/ // © relevantLeader16058 //@version=4 strategy(shorttitle='Maximized Moving Average Crossing ',title='Maximized Moving Average Crossing (by Coinrule)', overlay=true, initial_capital=1000, default_qty_type = strategy.percent_of_equity, default_qty_value = 30, commission_type=strategy.commission.percent, commission_value=0.1) //Backtest dates fromMonth = input(defval = 1, title = "From Month", type = input.integer, minval = 1, maxval = 12) fromDay = input(defval = 1, title = "From Day", type = input.integer, minval = 1, maxval = 31) fromYear = input(defval = 2020, title = "From Year", type = input.integer, minval = 1970) thruMonth = input(defval = 1, title = "Thru Month", type = input.integer, minval = 1, maxval = 12) thruDay = input(defval = 1, title = "Thru Day", type = input.integer, minval = 1, maxval = 31) thruYear = input(defval = 2112, title = "Thru Year", type = input.integer, minval = 1970) showDate = input(defval = true, title = "Show Date Range", type = input.bool) start = timestamp(fromYear, fromMonth, fromDay, 00, 00) // backtest start window finish = timestamp(thruYear, thruMonth, thruDay, 23, 59) // backtest finish window window() => time >= start and time <= finish ? true : false // create function "within window of time" //MA inputs and calculations inlong=input(50, title='MA long period') inshort=input(9, title='MA short period') MAlong = sma(close, inlong) MAshort= sma(close, inshort) // RSI inputs and calculations lengthRSI = (14) RSI = rsi(close, lengthRSI) RSI_Signal = input(55, title = 'RSI Trigger', minval=1) //Entry and Exit bullish = crossover(MAshort, MAlong) bearish = crossunder(MAshort, MAlong) strategy.entry(id="long", long = true, when = bullish and RSI > RSI_Signal and window()) strategy.close(id="long", when = bearish and window()) plot(MAshort, color=color.purple, linewidth=2) plot(MAlong, color=color.red, linewidth=2)