
이 전략은 부린 반지와 상대적으로 강한 지표 ((RSI) 를 결합하여 매매 신호를 판단한다. 가격이 부린 반지 경로를 돌파하고 RSI가 설정된 하위 한계보다 낮으면 매매 신호를 생성한다. 가격이 부린 반지 경로를 돌파하고 RSI가 설정된 상위 한계보다 높으면 매매 신호를 생성한다. 이 전략은 또한 매매 간격 변수를 도입하여 자주 거래를 피하고 피라미드형 포지션 관리를 구현하는 데 도움이 된다.
이 전략은 두 가지의 고전적인 기술 지표인 브린 띠와 RSI를 교묘하게 결합하여 트렌드 기회를 잡기 위해 이중 확인 메커니즘을 사용합니다. 동시에, 전략은 피라미드 형태의 포지션 구축 방법을 도입하여 위험을 통제하면서 수익을 최적화하려고합니다. 그러나 전략에는 추세 지속 위험, 변수 최적화 위험 및 블랙 스윙 사건 위험도 있습니다.
/*backtest
start: 2024-02-01 00:00:00
end: 2024-02-29 23:59:59
period: 1h
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/
//@version=4
strategy(overlay=true, shorttitle="cakes'Strategy For RSI", default_qty_type = strategy.percent_of_equity, initial_capital = 100000, default_qty_value = 100, pyramiding = 0, title="cakes'Strategy", currency = 'USD')
////////// ** Inputs ** //////////
// Stoploss and Profits Inputs
v1 = input(true, title="GoTradePlz")
////////// ** Indicators ** //////////
// RSI
len = 14
src = close
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
// Bollinger Bands
length1 = 20
src1 = close
mult1 = 1.0
basis1 = sma(src1, length1)
dev1 = mult1 * stdev(src1, length1)
upper1 = basis1 + dev1
lower1 = basis1 - dev1
////////// ** Triggers and Guards ** //////////
// 输入
RSILowerLevel1 = input(30, title="RSI 下限水平")
RSIUpperLevel1 = input(70, title="RSI 上限水平")
// 购买间隔
buyInterval = input(5, title="购买间隔(K线数量)")
// 跟踪购买间隔
var int lastBuyBar = na
lastBuyBar := na(lastBuyBar[1]) ? bar_index : lastBuyBar
// 策略信号
BBBuyTrigger1 = close < lower1
BBSellTrigger1 = close > upper1
rsiBuyGuard1 = rsi < RSILowerLevel1
rsiSellGuard1 = rsi > RSIUpperLevel1
Buy_1 = BBBuyTrigger1 and rsiBuyGuard1 and (bar_index - lastBuyBar) >= buyInterval
Sell_1 = BBSellTrigger1 and rsiSellGuard1
if (Buy_1)
lastBuyBar := bar_index
strategy.entry("Long", strategy.long, when = Buy_1, alert_message = "Buy Signal!")
strategy.close("Long", when = Sell_1, alert_message = "Sell Signal!")