This article mainly analyzes the quantitative trading strategy developed by Ravikant_sharma based on multiple exponential moving averages (EMA) and relative strength index (RSI). The strategy identifies price trends and determines entry and exit points by crossing EMAs with different cycles and values of RSI.
The strategy uses 5 EMAs with different periods, including 9-day, 21-day, 51-day, 100-day and 200-day lines. Only the first 4 EMAs are plotted in the code. The RSI parameter is set to 14.
One of the following conditions must be met before buying:
At the same time, RSI must be greater than 65, indicating a strong uptrend.
One of the following conditions must be met before closing the position:
It is a typical trend following strategy with the following strengths:
There are still some risks:
The strategy can be further optimized in the following ways:
In conclusion, this is an overall reliable and easy-to-implement trend following strategy. With EMA crossover for trend direction and RSI filter for false signals, good backtest results provide a solid foundation for further parameter and model optimization to obtain steady profits. However, traders should still be cautious of sharp reversals and improper parameters that pose risks.
/*backtest start: 2024-01-30 00:00:00 end: 2024-02-29 00:00:00 period: 3h 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/ // © Ravikant_sharma //@version=5 strategy('new', overlay=true) start = timestamp(1990, 1, 1, 0, 0) end = timestamp(2043, 12, 12, 23, 59) ema0 = ta.ema(close, 9) ema1 = ta.ema(close, 21) ema2 = ta.ema(close, 51) ema3 = ta.ema(close, 100) ema4 = ta.ema(close, 200) rsi2=ta.rsi(ta.sma(close,14),14) plot(ema0, '9', color.new(color.green, 0)) plot(ema1, '21', color.new(color.black, 0)) plot(ema2, '51', color.new(color.red, 0)) plot(ema3, '200', color.new(color.blue, 0)) //plot(ema4, '100', color.new(color.gray, 0)) //LongEntry = ( ta.crossover(ema0,ema3) or ta.crossover(ema0,ema2) or ta.crossunder(ema2,ema3) ) // ta.crossover(ema0,ema1) // LongEntry=false if ta.crossover(ema0,ema1) if rsi2>65 LongEntry:=true if ta.crossover(ema1,ema2) if rsi2>65 LongEntry:=true LongExit = ta.crossunder(ema0,ema2) or close >(strategy.position_avg_price*1.25) or rsi2 <40 or close < (strategy.position_avg_price*0.98) if time >= start and time <= end if(LongEntry and rsi2>60) strategy.entry('Long', strategy.long, 1) if(LongExit) strategy.close('Long')