스토카스틱 + RSI, 이중 전략

저자:차오장, 날짜: 2022-05-25 16:12:14
태그:스톡RSI

이 전략은 고전적인 RSI 전략을 결합하여 RSI가 70보다 높을 때 판매 (또는 30 이하로 떨어지면 구매) 하고, 고전적인 스토카스틱 슬로우 전략을 결합하여 스토카스틱 오시레이터가 80의 값을 초과할 때 판매 (그리고 이 값이 20 이하일 때 구매) 합니다.

이 간단한 전략은 RSI와 스토카스틱이 모두 과잉 구매 또는 과잉 판매 상태에서 함께 있을 때만 작동합니다. S&P 500의 한 시간 차트는 최근에 이 두 가지 전략으로 꽤 잘 작동했습니다.

이 전략은 스토카스틱 RSI와 혼동해서는 안 됩니다.

모든 거래는 높은 위험을 포함하고 있습니다. 과거의 성과가 반드시 미래의 결과를 나타내는 것은 아닙니다.

백테스트

img


/*backtest
start: 2022-04-24 00:00:00
end: 2022-05-23 23:59:00
period: 30m
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("Stochastic + RSI, Double Strategy (by ChartArt)", shorttitle="CA_-_RSI_Stoch_Strat", overlay=true)

// ChartArt's Stochastic Slow + Relative Strength Index, Double Strategy
//
// Version 1.0
// Idea by ChartArt on October 23, 2015.
//
// This strategy combines the classic RSI
// strategy to sell when the RSI increases
// over 70 (or to buy when it falls below 30),
// with the classic Stochastic Slow strategy
// to sell when the Stochastic oscillator
// exceeds the value of 80 (and to buy when
// this value is below 20).
//
// This simple strategy only triggers when
// both the RSI and the Stochastic are together
// in overbought or oversold conditions.
//
// List of my work: 
// https://www.tradingview.com/u/ChartArt/


///////////// Stochastic Slow
Stochlength = input(14, minval=1, title="lookback length of Stochastic")
StochOverBought = input(80, title="Stochastic overbought condition")
StochOverSold = input(20, title="Stochastic oversold condition")
smoothK = input(3, title="smoothing of Stochastic %K ")
smoothD = input(3, title="moving average of Stochastic %K")
k = sma(stoch(close, high, low, Stochlength), smoothK)
d = sma(k, smoothD)

 
///////////// RSI 
RSIlength = input( 14, minval=1 , title="lookback length of RSI")
RSIOverBought = input( 70  , title="RSI overbought condition")
RSIOverSold = input( 30  , title="RSI oversold condition")
RSIprice = close
vrsi = rsi(RSIprice, RSIlength)


///////////// Double strategy: RSI strategy + Stochastic strategy

if (not na(k) and not na(d))
    if (crossover(k,d) and k < StochOverSold)
        if (not na(vrsi)) and (crossover(vrsi, RSIOverSold))
            strategy.entry("LONG", strategy.long, comment="StochLE + RsiLE")
 
 
if (crossunder(k,d) and k > StochOverBought)
    if (crossunder(vrsi, RSIOverBought))
        strategy.entry("SHORT", strategy.short, comment="StochSE + RsiSE")
 
 
//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)

관련

더 많은