RSI Breakout VWAP 전략

저자:차오장, 날짜: 2023-09-11 14:13:35
태그:

이 전략은 VWAP에 RSI 지표를 적용하고, RSI 임계 폭파를 기반으로 긴 / 짧은 방향을 결정합니다. 구체적으로, RSI가 과소매 수준을 넘어서면 짧고, RSI가 과소매 수준을 넘어서면 길게됩니다. 또한 일정 기간 동안 연속적인 임계 폭파 후에 힘을 빠져 나갑니다.

이 전략의 장점은 오버바운드/오버셀드와 가격 트렌드에서 RSI와 VWAP를 모두 활용하여 잘못된 신호를 필터링하는 데 도움이 됩니다. 그러나 트렌드 역전을 식별하는 데 지연될 위험이 있습니다. RSI 매개 변수와 연속적인 브레이크 아웃 기간을 세밀하게 조정하면 전략을 최적화 할 수 있습니다.

요약하자면, RSI 브레이크업 VWAP 전략은 여러 지표를 결합하여 거래 기회를 식별하지만 다른 시장 조건에 적응하기 위해 신중한 테스트와 조정을 필요로합니다. 이 전략을 장기적으로 적용하려면 위험을 제어하는 것이 중요합니다.


/*backtest
start: 2022-09-04 00:00:00
end: 2023-09-10 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"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/
// © Mysteriown

//@version=4

strategy("RSI on VWAP Upgraded strategy", overlay=false, pyramiding = 3, commission_value = 0.04)
// pyramiding is the number of positions you can take before closing all of them (be carefull if using it with a trading bot)
// commission_value is the commission taken for each buy/sell



// ------------------------------------------ //
// ----------------- Inputs ----------------- //
// ------------------------------------------ //

length = input(20, title="RSI Length", type=input.integer)
ovrsld = input(30, "RSI Oversold level", type=input.float)
ovrbgt = input(85, "RSI Overbought level", type=input.float)
lateleave = input(28, "Number of candles", type=input.integer)
// lateleave : numbers of bars in overbought/oversold zones where the position is closed. The position is closed when this number is reached or when the zone is left (the first condition).

// best parameters BTCUSDTPERP M15 : 20 / 30 / 85 / 28


stratbull = input(title="Enter longs ?", type = input.bool, defval=true)
stratbear = input(title="Enter shorts ?", type = input.bool, defval=true)
bet = input(0.1, "Amount of coin/token by position", type=input.float)

stratyear = input(2020, title = "Strategy Start Year")
stratmonth = input(7, title = "Strategy Start Month")
stratday = input(1, title = "Strategy Start Day")
stratstart = timestamp(stratyear,stratmonth,stratday,0,0)


// ------------------------------------------ //
// ---------------- Rsi VWAP ---------------- //
// ------------------------------------------ //

rsiVWAP = rsi(vwap(close), length)


// ------------------------------------------ //
// ------------------ Plots ----------------- //
// ------------------------------------------ //

prsi = plot(rsiVWAP, color = rsiVWAP>ovrbgt ? color.red : rsiVWAP<ovrsld ? color.green : color.white, title="RSI on VWAP", linewidth=1, style=plot.style_line)
hline = plot(ovrbgt, color = color.gray, style=plot.style_line)
lline = plot(ovrsld, color = color.gray, style=plot.style_line)
fill(prsi,hline, color = rsiVWAP > ovrbgt ? color.red : na, transp = 30)
fill(prsi,lline, color = rsiVWAP < ovrsld ? color.green : na, transp = 30)


// ------------------------------------------ //
// ---------------- Positions --------------- //
// ------------------------------------------ //

if stratbull and time > stratstart
    strategy.entry("Long", true, bet, when = crossover(rsiVWAP, ovrsld), comment="")
    strategy.close("Long", when = crossover(rsiVWAP, ovrbgt)[lateleave] or crossunder(rsiVWAP, ovrbgt), comment="")

if stratbear and time > stratstart
    strategy.entry("Short", false, bet, when = crossunder(rsiVWAP, ovrbgt), comment="")
    strategy.close("Short", when = crossunder(rsiVWAP, ovrsld)[lateleave] or crossover(rsiVWAP, ovrsld), comment="")

더 많은