
이 전략은 쌍파역 지표를 사용하여 평형 영역을 식별하고, 브레이크 전략과 함께 낮은 가격의 거래 전략을 구현합니다. 가격이 중립 영역을 뚫을 때, 가격이 새로운 트렌드를 시작한다는 것을 나타냅니다. 이 때 더 많은 입장이 이루어집니다. 가격이 중립 영역을 다시 넘어지면, 가격 트렌드가 끝난 것을 나타냅니다. 이 때 평형 상태입니다.
이 전략은 두 개의 브린 대역을 사용한다. 내부 브린 대역의 상하계는 20일 간소 이동 평균 ± 1배 표준 차; 외부 브린 대역의 상하계는 20일 간소 이동 평균 ± 2배 표준 차이다. 가격이 내부와 외부 브린 대역 사이에 있을 때 중립 영역으로 정의된다.
가격이 연속적으로 2개의 K선으로 중립 영역에 있을 때, 평형 상태에 있다고 간주한다. 가격이 연속적으로 2개의 K선으로 평형된 후, 3번째 K선으로 평형된 가격이 네브린 띠를 넘어서면, 다중 신호를 발생한다.
더 많이 할 때, 최소 가격으로 2배의 ATR으로 중지 라인을 설정하여 수익을 잠금하고 위험을 제어합니다. 가격이 네브린 띠로 경로를 넘어지면 평점.
이 전략은 지표와 트렌드 두 가지 요소를 결합하여 조정 영역을 식별하고 가격이 새로운 트렌드를 시작했는지 판단할 수 있으며, 낮은 가격과 높은 가격으로 수익을 얻을 수 있습니다. 중지 손실 전략은 수익을 고정하고 위험을 제어하여 전략의 안정성을 높일 수 있습니다.
이 전략은 가격의 브레이크 브린을 경로에 형성하는 다중 신호에 의존하고 있으며, 만약 가짜 브레이크가 발생하면, 오차와 손실이 발생한다. 또한, 스톱포인트가 너무 가까이 있으면 초 스톱포드가 발생할 수 있다.
부린띠의 매개 변수를 최적화하고, 필터링 조건을 증가시키는 등의 방법을 통해 가짜 돌파의 가능성을 줄일 수 있다. 또한, 적절히 느슨한 스톱포인트를 사용하여 충분한 공간이 확보될 수 있다.
이 전략은 쌍파역 지표와 트렌드 전략을 통합하여 낮은 가격과 높은 가격으로 거래할 수 있으며 수익이 큰 편이다. 동시에, 스톱로스 전략은 전략을 안정적으로 만듭니다. 추가적인 최적화를 통해 전략 효과를 높일 수 있으며 실무에서 검증할 가치가 있습니다.
/*backtest
start: 2022-12-06 00:00:00
end: 2023-12-12 00:00:00
period: 1d
basePeriod: 1h
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/
// © DojiEmoji
//@version=4
strategy("[KL] Double BB Strategy",overlay=true,pyramiding=1)
ENUM_LONG = "LONG"
// Timeframe {
backtest_timeframe_start = input(defval = timestamp("01 Apr 2020 13:30 +0000"), title = "Backtest Start Time", type = input.time)
USE_ENDTIME = input(false,title="Define backtest end-time (If false, will test up to most recent candle)")
backtest_timeframe_end = input(defval = timestamp("19 Apr 2021 19:30 +0000"), title = "Backtest End Time (if checked above)", type = input.time)
within_timeframe = true
// }
// Bollinger bands
BOLL_length = 20, BOLL_src = close, SMA20 = sma(BOLL_src, BOLL_length)
BOLL_sDEV = stdev(BOLL_src, BOLL_length)
BOLL_upper1 = SMA20 + BOLL_sDEV, BOLL_lower1 = SMA20 - BOLL_sDEV
BOLL_upper2 = SMA20 + BOLL_sDEV*2, BOLL_lower2 = SMA20 - BOLL_sDEV*2
SMA_20_plot = plot(SMA20, "Basis", color=#872323, offset = 0)
BOLL_upper1_plot = plot(BOLL_upper1, "BOLL Upper1", color=color.navy, offset = 0, transp=50)
BOLL_lower1_plot = plot(BOLL_lower1, "BOLL Lower1", color=color.navy, offset = 0, transp=50)
BOLL_upper2_plot = plot(BOLL_upper2, "BOLL Upper2", color=color.navy, offset = 0, transp=50)
BOLL_lower2_plot = plot(BOLL_lower2, "BOLL Lower2", color=color.navy, offset = 0, transp=50)
fill(BOLL_upper2_plot, BOLL_upper1_plot, title = "Background", color=#198787, transp=85)
fill(BOLL_upper1_plot, SMA_20_plot, title = "Background", color=#198787, transp=75)
fill(SMA_20_plot, BOLL_lower1_plot, title = "Background", color=#198787, transp=75)
fill(BOLL_lower1_plot, BOLL_lower2_plot, title = "Background", color=#198787, transp=85)
// Trailing stop loss {
ATR_X2_TSL = atr(input(14,title="Length of ATR for trailing stop loss")) * input(2.0,title="ATR Multiplier for trailing stop loss",type=input.float)
TSL_source = low
var stop_loss_price = float(0)
TSL_line_color = color.green, TSL_transp = 100
if strategy.position_size == 0 or not within_timeframe
TSL_line_color := color.black
stop_loss_price := TSL_source - ATR_X2_TSL
else if strategy.position_size > 0
stop_loss_price := max(stop_loss_price, TSL_source - ATR_X2_TSL)
TSL_transp := 0
plot(stop_loss_price, color=color.new(TSL_line_color, TSL_transp))
// }
// Signals for entry
is_neutral = close < BOLL_upper1 and close > BOLL_lower2
is_consol = is_neutral and is_neutral[2]
entry_signal = is_consol[1] and close > BOLL_upper1
// MAIN:
if within_timeframe
// EXIT ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
exit_msg = close <= strategy.position_avg_price ? "stop loss" : "take profit"
end_of_rally = close < BOLL_upper1 and strategy.position_avg_price > stop_loss_price // also detects false breakouts
if strategy.position_size > 0 and (TSL_source <= stop_loss_price or end_of_rally)
strategy.close(ENUM_LONG, comment=exit_msg)
// ENTRY :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (strategy.position_size == 0 or (strategy.position_size > 0 and close > stop_loss_price)) and entry_signal
entry_msg = strategy.position_size > 0 ? "adding" : "initial"
strategy.entry(ENUM_LONG, strategy.long, comment=entry_msg)
// CLEAN UP:
if strategy.position_size == 0
stop_loss_price := float(0)