볼링거 피보나치 그리드 트렌드 추적 전략

저자:차오장, 날짜: 2023-12-13 17:12:38
태그:

img

전반적인 설명

이 전략은 ATR 및 피보나치 리트레이싱을 기반으로 한 가격 채널을 그리기 위해 볼링거 밴드 지표를 사용합니다. 전체 트렌드 방향을 결정하기 위해 이중 EMA 라인과 결합하여 트렌드 추적 중재를 달성하기 위해 트렌드 방향으로 볼링거 가격 밴드에서 선택적으로 후속 스톱 로스 그리드를 설정합니다.

전략 원칙

  1. 볼린거 밴드의 중간선과 ATR 및 4 피보나치 리트레이싱 라인으로부터 구성된 상부 및 하부 레일을 사용하여 가격 파동 밴드를 구성합니다.

  2. 빠른 EMA 라인과 느린 SMA 라인은 전반적인 트렌드 방향을 결정하기 위해 이중 이동 평균을 형성합니다. 느린 라인을 뚫는 빠른 라인은 황소 시장이며 반대로 곰 시장입니다.

  3. 황소 시장에서, 단지 길게 가서, 채널의 바닥을 뚫고 긴 포지션을 열기 위해 볼링거 밴드의 하부 레일 근처의 가격을 선택하십시오. 곰 시장에서, 단지 짧게 가서, 채널의 상부를 뚫고 짧은 포지션을 열기 위해 볼링거 밴드의 상부 레일 근처의 가격을 선택하십시오.

  4. 정지 손실 조건을 설정: 큰 반전 바가 나타나면 현재 방향 위치를 종료합니다.

이점 분석

  1. 트렌드 트렌드를 피하기 위해 두 배 이동 평균을 사용하여 메가 레벨 트렌드를 결정합니다.

  2. 볼링거 ATR 채널 그리드는 포지션을 성공적으로 개설할 확률을 높이기 위해 여러 개 개척 가격을 설정합니다.

  3. 피보나치 리트레이스 웨이브 밴드는 가격 변동성을 설정하고, 다른 밴드에서 다른 수의 포지션을 가지고 자본 분산을 달성합니다.

  4. 실시간 스톱 로스 조건은 빠른 스톱 로스를 촉진하고 수익 재조치를 줄여줍니다.

위험 분석

  1. 메가 레벨 트렌드를 판단하는 오류는 반대 손실로 이어질 수 있습니다. 이동 평균 매개 변수를 적절히 조정하거나 보조 판단을 위해 다른 지표를 추가하십시오.

  2. 변동성이 너무 높을 때, 가격은 직렬 영역을 뚫고 진출할 수 없습니다. 거래 기회를 높이기 위해 파동 대역 매개 변수를 조정하십시오.

  3. 스톱 로스 조건은 더 주관적이며, 인식 기준은 거래자에 따라 다를 수 있습니다. 스톱 로스 조건을 테스트하고 최적화하는 것이 좋습니다.

최적화 방향

  1. 이중 이동 평균 추세 판단에 대한 보조 분석을 위한 APO 지표를 추가합니다.

  2. 시장 변동성 지표를 사용하여 볼링거 파동 대역 매개 변수를 최적화하여 역동적인 시장 변화에 더 잘 적응합니다.

  3. 스톱 손실 진폭을 줄이고 오류를 줄이기 위해 스톱 손실 조건을 설정하는 다른 방법을 추가합니다.

요약

이 전략의 전반적인 아이디어는 명확하다. 볼링거 ATR 채널과 이중 이동 평균을 결합하여 전략 거래 신호에 대한 포괄적 인 판단을 달성하여 잘못된 판단의 위험을 극대화합니다. 전략의 장점은 분명하며 실제 거래에서 적용 될 수 있습니다. 그러나 파라미터 설정 및 스톱 로스 조건과 같은 세부 사항에 대한 최적화에 여전히 여지가 있습니다. 지속적인 최적화로 이 전략의 수익성과 안정성이 계속 증가 할 것으로 믿어집니다.


/*backtest
start: 2023-11-12 00:00:00
end: 2023-12-12 00:00:00
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/
// © Aayonga

//@version=5
strategy("fib trend grid@Aa", overlay=true,initial_capital=2000, default_qty_type=strategy.fixed, default_qty_value=1)

//回测时间
useDateFilter=input.bool(true,title = "启用回测时间范围限定(backtest)", group = "回测范围(backtest)")
backtesStarDate=input(timestamp("1 Jan 2015"),title = "开始时间(Start)", group = "回测范围(backtest)")
backtestEndDate=input(timestamp("1 Jan 2040"),title = "结束时间(finish)",group = "回测范围(backtest)")
inTradeWindow=true


//入场位 entry
bolllen=input.int(defval=20,minval=1,title="布林长度,(boll length)",group = "入场位(entry)")
sma=ta.sma(close,bolllen)
avg=ta.atr(bolllen)
fib1=input(defval=1.236,title="Fib 1",group = "入场位(entry)")
fib2=input(defval=2.382,title="Fib 2",group = "入场位(entry)")
fib3=input(defval=3.618,title="fib 3",group = "入场位(entry)")
fib4=input(defval=4.236,title="Fib 4",group = "入场位(entry)")
r1=avg*fib1
r2=avg*fib2
r3=avg*fib3
r4=avg*fib4
top4=sma+r4
top3=sma+r3
top2=sma+r2
top1=sma+r1
bott1=sma-r1
bott2=sma-r2
bott3=sma-r3
bott4=sma-r4



//趋势 trend

t4=plot(top4,title="卖 (sell)4",color=color.rgb(244, 9, 9))
t3=plot(top3,title = "卖(sell) 3",color=color.rgb(211, 8, 8))
t2=plot(top2,title="卖 (sell)2",color=color.rgb(146, 13, 13))
t1=plot(top1,title="卖(sell) 1",color=color.rgb(100, 3, 3))

b1=plot(bott1,title="买(buy)1",color=color.rgb(4, 81, 40))
b2=plot(bott2,title="买(buy)2",color=color.rgb(15, 117, 46))
b3=plot(bott3,title = "买(buy)3",color =color.rgb(8, 176, 42) )
b4=plot(bott4,title="买(buy)4",color=color.rgb(15, 226, 103))
plot(sma,style=plot.style_cross,title="SMA",color=color.rgb(47, 16, 225))

//趋势
LengthF=input(defval = 25,title = "快线长度(fastlength)")
LengthS=input(defval=200,title = "慢线长度(slowlength)")
emaF=ta.ema(close,LengthF)
smaS=ta.sma(close,LengthS)
longTrend=emaF>smaS
longb=ta.crossover(emaF,smaS)
bgcolor(longb ? color.new(color.green,40):na,title = "多头强势(bull trend)")
shortTrend=smaS>emaF
shortb=ta.crossunder(emaF,smaS)
bgcolor(shortb ? color.new(#951313, 40):na,title = "空头强势(bear trend)")

//pinbar
bullPinBar = ((close > open) and ((open - low) > 0.6* (high - low))) or ((close < open) and ((close - low) > 0.9 * (high - low)))
//plotshape(bullPinBar  , text ="pinbar", textcolor=color.rgb(9, 168, 144),location=location.belowbar, color=color.rgb(29, 103, 67), size=size.tiny)
bearPinBar = ((close > open) and ((high - close) > 0.7 * (high - low))) or ((close < open) and ((high - open) > 0.7 * (high - low)))
//plotshape(bearPinBar  , text ="pinbar", textcolor=color.rgb(219, 12, 12),location=location.abovebar, color=color.rgb(146, 7, 7), size=size.tiny)

buy1=ta.crossunder(close,bott1) and longTrend and close>ta.ema(close,100)
buy2=ta.crossunder(close,bott2) and longTrend and close>ta.ema(close,80)
buy3=ta.crossunder(close,bott3) and longTrend and close>ta.ema(close,80)
buy4=ta.crossunder(close,bott4) and longTrend and close>ta.ema(close,80)
buyclose=bearPinBar or ta.crossunder(close,smaS)




if buy2 or buy3 or buy4 or buy1 and inTradeWindow
    strategy.order("多(buy)",strategy.long)

if buyclose  and inTradeWindow
    strategy.close("多(buy)")

sell1=ta.crossover(close,top1) and shortTrend and close<ta.ema(close,200)
sell2=ta.crossover(close,top2) and shortTrend and close<ta.ema(close,200)
sell3=ta.crossover(close,top3) and shortTrend and close<ta.ema(close,200)
sell4=ta.crossover(close,top4) and shortTrend and close<ta.ema(close,200)
sellclose=bullPinBar or ta.crossover(close,ta.sma(close,220))

if  sell1 or sell2 or sell3 or sell4 and inTradeWindow
    strategy.order("空(sell)",strategy.short)

if sellclose  and inTradeWindow
    strategy.close("空(sell)")
     

더 많은