트렌드 추적 중지 손실 취득 전략

저자:차오장날짜: 2024-01-24 14:17:28
태그:

img

전반적인 설명

이것은 트렌드 추적 전략으로 트렌드를 결정하기 위해 볼링거 밴드와 ATR을 사용하여 스톱 로스를 설정하고 이익을 취합니다. 먼저 시장 트렌드를 판단하고 트렌드 라인을 그리며 포지션을 닫을 때 스톱 로스를 설정하고 이익을 취합니다.

전략 논리

  1. 볼링거 밴드의 상부와 하부 레일을 계산합니다.
  2. 닫기 가격이 상위 레일 이상 또는 하위 레일 이하인지 판단합니다. 만약 그렇습니다. 트렌딩 시장, 각각 상승 또는 하락으로 판단하십시오.
  3. 트렌딩 시장이라면 트렌드 라인을 계산합니다. 트렌드 라인은 ATR 값 (가시 시장) 을 빼고 가장 낮은 가격 또는 ATR 값 (곰 시장) 을 더한 가장 높은 가격에 기초합니다.
  4. 트렌딩 시장이 아닌 경우, 트렌드 라인을 이전 바와 동일하게 유지하십시오.
  5. 트렌드 방향을 결정하기 위해 트렌드 라인을 비교하십시오. 상승 추세, 하락 추세.
  6. 트렌드 라인 방향이 변할 때 구매/판매 신호를 생성합니다.
  7. 스톱 로스를 설정하고 이윤을 취합니다. 고정 스톱 로스 거리는 입시 가격의 100배입니다. 부동 스톱 로프트는 입시 가격의 1.1배 (고양) 또는 0.9배 (곰) 입니다.

이점 분석

  1. 시장 트렌드를 결정하고 가짜 브레이크 트레이드를 피할 수 있습니다.
  2. 함정에 빠지지 않기 위해 트렌드 라인을 설정하십시오.
  3. 합리적인 스톱 로스 및 수익 설정으로 수익을 보장하면서 위험을 제어합니다.

위험 분석

  1. 부적절한 매개 변수 설정은 거래 기회를 놓칠 수 있습니다.
  2. 볼링거 밴드는 범위에 묶인 시장에서 잘못된 판단을 할 가능성이 높습니다.
  3. 너무 가까워지면 손해를 줄 수 있습니다.

최적화 방향

  1. 다양한 상품에 대한 볼링거 밴드 매개 변수를 최적화합니다.
  2. 트렌드 라인 계산 방법의 최적화, 예를 들어 다른 지표를 도입.
  3. 스톱 로스 및 수익 매개 변수 설정을 테스트하고 최적화합니다.

결론

이 전략은 볼링거 밴드를 사용하여 트렌드를 결정하고 트렌드 라인을 기반으로 스톱 로스를 설정하고 수익을 취하는 전략이다. 핵심 장점은 명확한 트렌드 판단, 합리적인 스톱 로스 및 수익을 취하는 설정으로 위험을 효과적으로 제어 할 수 있습니다. 주요 위험은 볼링거 밴드의 잘못된 트렌드 판단과 손실이 너무 가깝기 때문입니다. 미래 최적화 방향에는 매개 변수 최적화, 트렌드 라인 계산 최적화 및 스톱 로스 수익 최적화 등이 포함됩니다.


/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © zhuenrong

// © Dreadblitz
//@version=4
strategy(shorttitle="FLI", title="Follow Line Indicator", overlay=true)
// 
BBperiod      = input(defval = 21,     title = "BB Period",    type = input.integer, minval = 1)
BBdeviations  = input(defval = 1.00,     title = "BB Deviations",    type = input.float, minval = 0.1, step=0.05)
UseATRfilter  = input(defval = true, title = "ATR Filter",  type = input.bool)
ATRperiod     = input(defval = 5,     title = "ATR Period",    type = input.integer, minval = 1)
hl            = input(defval = false, title = "Hide Labels",  type = input.bool)
//
BBUpper=sma (close,BBperiod)+stdev(close, BBperiod)*BBdeviations
BBLower=sma (close,BBperiod)-stdev(close, BBperiod)*BBdeviations
//
TrendLine = 0.0
iTrend = 0.0
buy = 0.0
sell = 0.0
//
BBSignal = close>BBUpper? 1 : close<BBLower? -1 : 0
// 
if BBSignal == 1 and UseATRfilter == 1
    TrendLine:=low-atr(ATRperiod)
    if TrendLine<TrendLine[1] 
        TrendLine:=TrendLine[1]
if BBSignal == -1 and UseATRfilter == 1
    TrendLine:=high+atr(ATRperiod)
    if TrendLine>TrendLine[1]
        TrendLine:=TrendLine[1]
if BBSignal == 0 and UseATRfilter == 1
    TrendLine:=TrendLine[1]
//
if BBSignal == 1 and UseATRfilter == 0
    TrendLine:=low
    if TrendLine<TrendLine[1] 
        TrendLine:=TrendLine[1]
if BBSignal == -1 and UseATRfilter == 0
    TrendLine:=high
    if TrendLine>TrendLine[1]
        TrendLine:=TrendLine[1]
if BBSignal == 0 and UseATRfilter == 0
    TrendLine:=TrendLine[1]
//
iTrend:=iTrend[1]
if TrendLine>TrendLine[1] 
    iTrend:=1
if TrendLine<TrendLine[1] 
    iTrend:=-1
//
buy:=iTrend[1]==-1 and iTrend==1 ? 1 : na
sell:=iTrend[1]==1 and iTrend==-1? 1 : na
//
plot(TrendLine, color=iTrend > 0?color.blue:color.red ,style=plot.style_line,linewidth=2,transp=0,title="Trend Line") 
plotshape(buy == 1 and hl == false? TrendLine-atr(8) :na, text='💣', style= shape.labelup, location=location.absolute, color=color.blue, textcolor=color.white, offset=0, transp=0,size=size.auto)
plotshape(sell == 1 and hl == false ?TrendLine+atr(8):na, text='🔨', style=shape.labeldown, location=location.absolute, color=color.red, textcolor=color.white, offset=0, transp=0,size=size.auto)
//
alertcondition(sell == 1 ,title="Sell",message="Sell")
alertcondition(buy == 1 ,title="Buy",message="Buy")
alertcondition(buy == 1 or sell == 1 ,title="Buy/Sell",message="Buy/Sell")
if (buy==1)
    strategy.entry("Buy", strategy.long)
if (sell==1)
    strategy.entry("Sell", strategy.short)
// === Stop LOSS ===

if strategy.position_size>0
    strategy.exit("Stop Loss/Profit Long","Buy", stop=strategy.position_avg_price*100, limit=strategy.position_avg_price*1.1)
if strategy.position_size<0
    strategy.exit("Stop Loss/Profit Short","Sell", stop=strategy.position_avg_price*100, limit=strategy.position_avg_price*0.9)

더 많은