라인 전략을 따르세요

저자:차오장, 날짜: 2023-12-01 18:31:39
태그:

img

전반적인 설명

팔로우 라인 전략 (Follow Line strategy) 은 볼링거 밴드 (Bollinger Bands) 와 평균 참 범위 (ATR) 를 기반으로 하는 트렌드 추적 전략이다. 가격이 볼링거 밴드 (Bollinger Bands) 상단단위에서 넘어설 때 상승하고, 가격이 볼링거 밴드 (Bollinger Bands) 하단단단위에서 넘어설 때 하단단단으로 이동하여 트렌드 판단 라인을 동적으로 조정하여 트렌드를 추적한다.

전략 논리

이 전략은 먼저 볼링거 밴드의 상위 및 하위 밴드와 평균 진실 범위를 계산합니다. 그 다음 가격이 볼링거 상위 밴드 이상 또는 하위 밴드 아래로 넘어갈지 판단합니다.

가격이 상단 범위를 넘을 때, ATR 필터가 활성화되면, 트렌드 라인은 ATR을 빼고 가장 낮은 가격으로 설정됩니다. ATR 필터가 비활성화되면, 트렌드 라인은 가장 낮은 가격으로 직접 설정됩니다.

가격이 하단 범위를 넘으면, ATR 필터가 활성화되면, 트렌드 라인은 가장 높은 가격과 ATR로 설정됩니다. ATR 필터가 비활성화되면, 트렌드 라인은 직접 가장 높은 가격으로 설정됩니다.

따라서, 트렌드 판단 라인은 경향을 추적하기 위해 볼링거 밴드의 가격 파업에 따라 동적으로 조정될 수 있습니다.

현재 트렌드 라인이 이전 라인보다 높으면 상승 추세를 나타냅니다. 현재 트렌드 라인이 이전 라인보다 낮으면 하락 추세를 나타냅니다.

트레이딩 신호는 트렌드 판단에 따라 길거나 짧을 수 있습니다.

이점 분석

  • 동적으로 조정되는 트렌드 라인은 가격 추세를 유연하게 파악할 수 있습니다.
  • 볼링거 밴드와 결합하면 밴드 브레이크에서 트렌드 반전을 적절히 판단 할 수 있습니다.
  • ATR 필터를 도입하면 일부 잘못된 신호를 피할 수 있습니다.

위험 분석

  • 부적절한 BB 매개 변수는 빈번한 거짓 파장을 일으킬 수 있습니다.
  • 과도한 ATR 매개 변수는 트렌드 반전 기회를 놓칠 수 있습니다.
  • 극단적인 움직임으로 인한 손실을 방지하기 위해 손실을 중지하는 것을 고려해야 합니다.

일부 위험은 매개 변수 조정을 통해 완화 될 수 있으며, 스톱 로스를 도입할 수 있습니다. 또한 브레이크오웃 유효성을 향상시키기 위해 신호 필터링을 위한 다른 지표와 결합할 수 있습니다.

최적화 방향

  • 최고의 구성을 찾기 위해 BB와 ATR 매개 변수를 최적화
  • 가짜 브레이크를 필터링하기 위해 다른 지표를 추가합니다.
  • 특정 거래 수단에 기초한 BB 및 ATR 기간을 선택

결론

팔로우 라인 전략은 변동적인 시장에서 가격 트렌드를 파악하는 것을 목표로 한다. 이는 효과적인 트렌드 추적 전략이다. 적절한 매개 변수 조정 및 최적화는 적당한 수익을 가져올 수 있다. 그러나 위험은 스톱 로스로 관리되어야 하며 잘못된 브레이크오트를 방지해야 한다. 이 전략을 다른 지표 또는 전략과 결합하여 수익성을 더욱 향상시키는 것이 좋습니다.


/*backtest
start: 2023-11-23 00:00:00
end: 2023-11-30 00:00:00
period: 10m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// © Dreadblitz
//@version=4
//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ //

strategy(title = " Strategy Follow Line Indicator ",
         shorttitle = "S-FLI",
         overlay = true,
         precision = 8,
         calc_on_order_fills = true,
         calc_on_every_tick = true,
         backtest_fill_limits_assumption = 0,
         default_qty_type = strategy.fixed,
         default_qty_value = 2,
         initial_capital = 10000,
         pyramiding=1,
         currency = currency.USD,
         linktoseries = true)

//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ //

backTestSectionFrom = input(title = "═══════════════ From ═══════════════", defval = true, type = input.bool)

FromMonth         = input(defval = 1, title = "Month", minval = 1)
FromDay           = input(defval = 1, title = "Day", minval = 1)
FromYear          = input(defval = 2014, title = "Year", minval = 2000)

backTestSectionTo = input(title = "════════════════ To ════════════════", defval = true, type = input.bool)
ToMonth           = input(defval = 31, title = "Month", minval = 1)
ToDay             = input(defval = 12, title = "Day", minval = 1)
ToYear            = input(defval = 9999, title = "Year", minval = 2000)

Config            = input(title = "══════════════ Config ══════════════", defval = true, type = input.bool)
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)


backTestPeriod() => true

//
//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ //

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)

// Strategy Entry
if (backTestPeriod())
    strategy.entry("long", true, 1, when = buy == 1)
    strategy.entry("short", false, 1, when = sell == 1) 

더 많은