该策略结合了随机RSI和EMA来检测趋势和验证交易信号。当价格在EMA20上方回调到EMA9和EMA14之间,同时随机RSI低于超卖水平时产生做多信号;当价格在EMA20下方回调到EMA9和EMA14之间,同时随机RSI高于超买水平时产生做空信号。
该策略的核心思想是利用随机RSI来判断价格在主趋势(由EMA20表示)中的回调是否到达了合适的超买超卖区域,同时用快速EMA和中速EMA来验证回调的力度,如果价格突破快速EMA和中速EMA则回调可能结束,趋势可能反转,此时不适合入场,只有价格回调到EMA9和EMA14之间时才考虑顺势入场。这种多重条件验证的方式可以有效提高信号质量并减少误判。
该策略采用随机RSI结合EMA的多重条件验证,在把握趋势回调的同时有效控制了风险,整体思路简单易懂,适合新手学习使用。但是策略本身也存在一些局限性,如对震荡市表现不佳,趋势行情把握不足等,需要根据实际情况灵活调整参数。后续还可以考虑从动态参数、更多指标验证、资金管理等方面对策略进行优化和提升,以期获得更稳健的收益。总的来说,该策略可以作为一个基础模板,在此基础上进行修改和扩展,是一个不错的出发点和学习素材。
/*backtest
start: 2023-03-02 00:00:00
end: 2024-03-07 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Crypto-EMA_Pullback=-", overlay=true,initial_capital = 10000000,default_qty_type=strategy.percent_of_equity, default_qty_value=10.0, pyramiding = 10)
// Inputs
lengthRsi = input(14, title="RSI Length")
k = input(3, title="Stoch %K")
d = input(3, title="Stoch %D")
lengthStoch = input(14, title="Stochastic RSI Length")
overSold = input(25, title="Oversold Level")
overBought = input(85, title="Overbought Level")
emaFastLength = input(9, title="Fast EMA Length")
emaMediumLength = input(14, title="Medium EMA Length")
emaSlowLength = input(20, title="Slow EMA Length")
// Calculating EMAs
emaFast = ta.ema(close, emaFastLength)
emaMedium = ta.ema(close, emaMediumLength)
emaSlow = ta.ema(close, emaSlowLength)
// Calculating the RSI and Stoch RSI
rsi = ta.rsi(close, lengthRsi)
stochRsiK = ta.sma(ta.stoch(rsi, rsi, rsi, lengthStoch), k)
stochRsiD = ta.sma(stochRsiK, d)
// Entry Conditions
bullishCondition = close > emaSlow and close < emaFast and close < emaMedium and stochRsiK < overSold
bearishCondition = close < emaSlow and close > emaFast and close > emaMedium and stochRsiK > overBought
// Strategy Execution
if (bullishCondition)
strategy.entry("Long", strategy.long)
if (bearishCondition)
strategy.entry("Short", strategy.short)
// Plotting
plot(emaFast, color=color.blue, title="Fast EMA")
plot(emaMedium, color=color.orange, title="Medium EMA")
plot(emaSlow, color=color.red, title="Slow EMA")
hline(overSold, "Oversold", color=color.green)
hline(overBought, "Overbought", color=color.red)