3가지 중복된 슈퍼트렌드 전략

저자:차오장, 날짜: 2024-02-26 10:04:18
태그:

img

전반적인 설명

이것은 3개의 중복된 슈퍼트렌드 지표를 기반으로 거래 결정을 내리는 전략입니다. 트렌딩 시장에서 더 큰 방향 기회를 포착할 수 있습니다.

전략 논리

이 전략은 ta.supertrend (() 함수를 사용하여 다른 매개 변수 설정으로 세 개의 슈퍼 트렌드 지표를 계산합니다. 즉, 10 일과 3 곱하기, 14 일과 2 곱하기, 20 일과 2.5 곱하기, 슈퍼 트렌드 2와 슈퍼 트렌드 3. 가격이 세 개의 슈퍼 트렌드 라인을 넘을 때 구매 신호가 생성됩니다. 가격이 세 개의 슈퍼 트렌드 라인을 넘을 때 판매 신호가 생성됩니다.

슈퍼 트렌드 지표는 가격 트렌드 변화를 효과적으로 추적하기 위해 ATR 지표를 통합합니다. 3 개의 중복된 슈퍼 트렌드의 전략은 신호를 더 신뢰할 수있게 만들고, 트렌딩 시장에서 더 큰 이익을 얻을 수 있습니다.

장점

  1. 삼중 필터 메커니즘은 잘못된 신호를 피하고 신호 품질을 향상시킵니다.
  2. 슈퍼트렌드 자체는 좋은 노이즈 감축 기능을 가지고 있습니다
  3. 하이퍼 파라미터의 여러 조합은 더 많은 시장 환경에 맞게 구성될 수 있습니다.
  4. 높은 리스크 수익률과 함께 좋은 역사적 성과

위험성

  1. 여러 필터링 신호가 몇 가지 기회를 놓칠 수 있습니다.
  2. 다양한 시장에서 좋은 성과를 거두지 못합니다.
  3. 하이퍼 파라미터 세 세트의 조합의 최적화를 요구합니다.
  4. 집중된 거래 시간은 갑작스러운 사건에 민감합니다.

위험을 줄이기 위해 다음을 고려할 수 있습니다.

  1. 필터링 조건을 조정, 하나 또는 두 개의 슈퍼 트렌드를 유지
  2. 스톱 로스 전략을 추가
  3. 승률을 높이기 위해 하이퍼 파라미터 최적화

최적화 방향

  1. 최적의 하이퍼 파라미터를 찾기 위해 더 많은 파라미터 조합을 테스트
  2. 실시간 매개 변수 최적화를 위한 기계 학습 알고리즘을 추가
  3. 단일 손실을 제어하기 위해 중지 손실 전략을 추가
  4. 추세와 범위를 식별하기 위해 다른 지표를 포함합니다.
  5. 단일 시간점에 위험을 피하기 위해 거래 시간을 연장

결론

이 전략은 트렌드 방향을 효과적으로 식별할 수 있는 3개의 중복된 슈퍼트렌드를 기반으로 결정을 내린다. 높은 신호 품질과 구성 가능한 매개 변수와 같은 장점이 있다. 동시에, 특정 위험도 있다. 매개 변수와 출구 타이밍은 다른 시장 환경에 적응하도록 조정되어야 한다. 전반적으로, 전략은 예외적으로 잘 수행되며 추가 연구와 적용 가치가 있다.


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

//@version=5
strategy('Combined Supertrend Strategy - Ajit Prasad', overlay=true)

// Function to calculate Supertrend
supertrendFunc(atrLength, factor) =>
    [supertrend, direction] = ta.supertrend(factor, atrLength)
    [supertrend, direction]

// Input parameters for the first Supertrend
atrPeriod1 = input(10, 'ATR Length 1')
factor1 = input(3, 'Factor 1')

// Calculate the first Supertrend
[supertrend1, direction1] = supertrendFunc(atrPeriod1, factor1)

// Input parameters for the second Supertrend
atrPeriod2 = input(14, 'ATR Length 2') // Change values as needed
factor2 = input(2, 'Factor 2') // Change values as needed

// Calculate the second Supertrend
[supertrend2, direction2] = supertrendFunc(atrPeriod2, factor2)

// Input parameters for the third Supertrend
atrPeriod3 = input(20, 'ATR Length 3') // Change values as needed
factor3 = input(2.5, 'Factor 3') // Change values as needed

// Calculate the third Supertrend
[supertrend3, direction3] = supertrendFunc(atrPeriod3, factor3)

// Define market opening and closing times
marketOpenHour = 9
marketOpenMinute = 15
marketCloseHour = 15
marketCloseMinute = 30
exitTimeHour = 15
exitTimeMinute = 10

// Fetch historical close values using security function
histClose = request.security(syminfo.tickerid, "D", close)

// Buy condition
buyCondition = close > supertrend1 and close > supertrend2 and close > supertrend3 and close[1] <= supertrend1[1]

// Sell condition
sellCondition = close < supertrend1 and close < supertrend2 and close < supertrend3 and close[1] >= supertrend1[1]

// Exit conditions
buyExitCondition = close < supertrend1[1] or close < supertrend2[1] or close < supertrend3[1]
sellExitCondition = close > supertrend1[1] or close > supertrend2[1] or close > supertrend3[1]

// Execute orders with market timing
if true
    // Buy condition without 'and not'
    strategy.entry('Buy', strategy.long, when = buyCondition)

    // Sell condition without 'and not'
    strategy.entry('Sell', strategy.short, when = sellCondition)

    // Close conditions
    strategy.close('Buy', when = buyExitCondition )
    strategy.close('Sell', when = sellExitCondition)

// Close all trades at 3:10 pm IST
if true
    strategy.close_all()

// Plot Supertrends
plot(supertrend1, 'Supertrend 1', color=color.new(color.green, 0), style=plot.style_linebr)
plot(supertrend2, 'Supertrend 2', color=color.new(color.red, 0), style=plot.style_linebr)
plot(supertrend3, 'Supertrend 3', color=color.new(color.blue, 0), style=plot.style_linebr)

// Plot labels
plotshape(buyCondition, style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), size=size.large, text='Buy Signal', textcolor=color.new(color.white, 0))
plotshape(sellCondition, style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), size=size.large, text='Sell Signal', textcolor=color.new(color.white, 0))

더 많은