브레이크오웃 및 지능형 볼링거 밴드 가격 채널 전략

저자:차오장, 날짜: 2024-01-05 13:14:11
태그:

img

전반적인 설명

이 전략은 차트에서 지원 및 저항 영역을 감지하기 위해 여러 시간 프레임 (1 분, 5 분, 15 분, 1 시간 및 4 시간) 을 결합하는 브레이크아웃 전략입니다.

전략 논리

이 전략은 지원 및 저항 구역을 결정하기 위해 볼링거 밴드 및 가격 채널을 사용합니다. 먼저 상위 및 하위 밴드를 결정하기 위해 각 시간 프레임에 대한 폐쇄 가격의 간단한 이동 평균 (SMA) 및 표준 편차 (STDEV) 를 계산합니다. 그 다음 거래 부피와 함께 지원 또는 저항 수준에서 가격 브레이크를 기반으로 결정되는 브레이커 블록 (Breaker Block) 을 감지합니다. 가격이 높은 볼륨으로 지원 또는 저항 수준에서 벗어날 때 브레이커 블록이 형성됩니다.

브레이커 블록이 검출되면 가격이 하부 대역을 넘으면 구매 신호가 생성되고 상부 대역을 넘으면 판매 신호가 생성됩니다. 전략은 또한 각 시간 프레임에 대한 가격 채널을 그래프화하여 지원 및 저항 수준을 나타냅니다.

또한, 전략은 각 시간 프레임에 대한 이익 제한 수준을 설정합니다. 이것은 포지션에 할당 된 가격 레벨이 이익으로 종료되어야한다는 것을 의미합니다. 손실을 제한하기 위해 중지 손실 수준도 설정됩니다.

이점 분석

  • 더 포괄적인 시장 트렌드 판단을 위해 여러 시간 프레임 분석을 사용합니다.
  • 브레이커 블록, 볼링거 밴드 채널 및 볼륨을 결합하면 신호가 더 신뢰할 수 있습니다.
  • 수익 및 중단 손실 목표를 설정하는 것은 위험 통제에 도움이됩니다

위험 분석

  • 부적절한 볼링거 밴드 매개 변수 설정으로 인해 잘못된 신호가 발생할 수 있습니다.
  • 브레이크업은 단기 시장 소음으로 인해
  • 여러 시간 프레임 판단 전략 복잡성을 증가

위험은 볼링거 매개 변수를 최적화하거나 보유 기간을 늘리거나 정지 설정으로 추가로 완화 될 수 있습니다.

최적화 방향

이 전략은 몇 가지 측면에서 최적화 될 수 있습니다.

  1. 실제 지원 및 저항을 더 잘 반영하기 위해 볼링거 매개 변수를 최적화하십시오.

  2. 브레이크오웃 방향과 모멘텀을 판단하는 머신 러닝 알고리즘을 추가합니다

  3. 최적의 출입 및 출입 시기를 결정하기 위해 변동성 지수를 포함합니다.

  4. 추세와 에너지를 결정하기 위해 MACD, KD와 같은 더 많은 지표를 결합

요약

이 전략은 멀티 타임프레임 기술 분석을 통합하고, 브레이크아웃 거래와 수익 스톱 손실 관리를 통해 위험을 관리합니다. 유연하고 신뢰할 수있는 브레이크아웃 시스템입니다. 그러나 실제 시장에 따라 매개 변수 조정 및 위험 통제는 지속적인 테스트와 최적화가 필요합니다.


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

//@version=5
strategy("DZ Strategy ICT", overlay=true)

// Paramètres de l'indicateur
length1 = input.int(14, minval=1, title='Longueur 1 min')
deviations1 = input.float(2.0, title='Déviations 1 min')
multiplier1 = input.float(1.0, minval=0.1, maxval=10, title='Multiplicateur 1 min')
fibonacciLevel1 = input.float(0.618, title='Niveau de Fibonacci 1 min')
displacement1 = input.int(3, minval=1, title='Décalage de Displacement 1 min')
volumeThreshold1 = input.float(1.0, minval=0, title='Seuil de Volume 1 min')
fibLevelInput1 = input.float(0.0, "Niveau de Limite de Profit 1 min", minval=0.0)

length5 = input.int(14, minval=1, title='Longueur 5 min')
deviations5 = input.float(2.0, title='Déviations 5 min')
multiplier5 = input.float(1.0, minval=0.1, maxval=10, title='Multiplicateur 5 min')
fibonacciLevel5 = input.float(0.618, title='Niveau de Fibonacci 5 min')
displacement5 = input.int(3, minval=1, title='Décalage de Displacement 5 min')
volumeThreshold5 = input.float(1.0, minval=0, title='Seuil de Volume 5 min')
fibLevelInput5 = input.float(0.0, "Niveau de Limite de Profit 5 min", minval=0.0)

length15 = input.int(14, minval=1, title='Longueur 15 min')
deviations15 = input.float(2.0, title='Déviations 15 min')
multiplier15 = input.float(1.0, minval=0.1, maxval=10, title='Multiplicateur 15 min')
fibonacciLevel15 = input.float(0.618, title='Niveau de Fibonacci 15 min')
displacement15 = input.int(3, minval=1, title='Décalage de Displacement 15 min')
volumeThreshold15 = input.float(1.0, minval=0, title='Seuil de Volume 15 min')
fibLevelInput15 = input.float(0.0, "Niveau de Limite de Profit 15 min", minval=0.0)

length60 = input.int(14, minval=1, title='Longueur 1 h')
deviations60 = input.float(2.0, title='Déviations 1 h')
multiplier60 = input.float(1.0, minval=0.1, maxval=10, title='Multiplicateur 1 h')
fibonacciLevel60 = input.float(0.618, title='Niveau de Fibonacci 1 h')
displacement60 = input.int(3, minval=1, title='Décalage de Displacement 1 h')
volumeThreshold60 = input.float(1.0, minval=0, title='Seuil de Volume 1 h')
fibLevelInput60 = input.float(0.0, "Niveau de Limite de Profit 1 h", minval=0.0)

length240 = input.int(14, minval=1, title='Longueur 4 h')
deviations240 = input.float(2.0, title='Déviations 4 h')
multiplier240 = input.float(1.0, minval=0.1, maxval=10, title='Multiplicateur 4 h')
fibonacciLevel240 = input.float(0.618, title='Niveau de Fibonacci 4 h')
displacement240 = input.int(3, minval=1, title='Décalage de Displacement 4 h')
volumeThreshold240 = input.float(1.0, minval=0, title='Seuil de Volume 4 h')
fibLevelInput240 = input.float(0.0, "Niveau de Limite de Profit 4 h", minval=0.0)

// Calcul des supports et résistances pour chaque plage de temps
basis1 = ta.sma(close, length1)
range_1 = multiplier1 * ta.stdev(close, length1)
upper1 = basis1 + deviations1 * range_1
lower1 = basis1 - deviations1 * range_1

basis5 = ta.sma(close, length5)
range_5 = multiplier5 * ta.stdev(close, length5)
upper5 = basis5 + deviations5 * range_5
lower5 = basis5 - deviations5 * range_5

basis15 = ta.sma(close, length15)
range_15 = multiplier15 * ta.stdev(close, length15)
upper15 = basis15 + deviations15 * range_15
lower15 = basis15 - deviations15 * range_15

basis60 = ta.sma(close, length60)
range_60 = multiplier60 * ta.stdev(close, length60)
upper60 = basis60 + deviations60 * range_60
lower60 = basis60 - deviations60 * range_60

basis240 = ta.sma(close, length240)
range_240 = multiplier240 * ta.stdev(close, length240)
upper240 = basis240 + deviations240 * range_240
lower240 = basis240 - deviations240 * range_240

// Calcul du volume moyen sur chaque période donnée
averageVolume1 = ta.sma(volume, length1)
averageVolume5 = ta.sma(volume, length5)
averageVolume15 = ta.sma(volume, length15)
averageVolume60 = ta.sma(volume, length60)
averageVolume240 = ta.sma(volume, length240)

// Détection du Breaker Block en fonction du déplacement et du volume pour chaque plage de temps
breakerBlock1 = ta.crossover(close[displacement1], lower1) and volume > volumeThreshold1 * averageVolume1
breakerBlock1 := breakerBlock1 or (ta.crossunder(close[displacement1], upper1) and volume > volumeThreshold1 * averageVolume1)

breakerBlock5 = ta.crossover(close[displacement5], lower5) and volume > volumeThreshold5 * averageVolume5
breakerBlock5 := breakerBlock5 or (ta.crossunder(close[displacement5], upper5) and volume > volumeThreshold5 * averageVolume5)

breakerBlock15 = ta.crossover(close[displacement15], lower15) and volume > volumeThreshold15 * averageVolume15
breakerBlock15 := breakerBlock15 or (ta.crossunder(close[displacement15], upper15) and volume > volumeThreshold15 * averageVolume15)

breakerBlock60 = ta.crossover(close[displacement60], lower60) and volume > volumeThreshold60 * averageVolume60
breakerBlock60 := breakerBlock60 or (ta.crossunder(close[displacement60], upper60) and volume > volumeThreshold60 * averageVolume60)

breakerBlock240 = ta.crossover(close[displacement240], lower240) and volume > volumeThreshold240 * averageVolume240
breakerBlock240 := breakerBlock240 or (ta.crossunder(close[displacement240], upper240) and volume > volumeThreshold240 * averageVolume240)

// Affichage du Breaker Block sur le graphique
bgcolor(breakerBlock1 ? color.new(color.yellow, 70) : na)
bgcolor(breakerBlock5 ? color.new(color.yellow, 70) : na)
bgcolor(breakerBlock15 ? color.new(color.yellow, 70) : na)
bgcolor(breakerBlock60 ? color.new(color.yellow, 70) : na)
bgcolor(breakerBlock240 ? color.new(color.yellow, 70) : na)

// Définition de la zone limite de l'ordre de profit pour chaque plage de temps
fibLevel1 = basis1 * fibonacciLevel1
fibLevel5 = basis5 * fibonacciLevel5
fibLevel15 = basis15 * fibonacciLevel15
fibLevel60 = basis60 * fibonacciLevel60
fibLevel240 = basis240 * fibonacciLevel240

// Signal d'achat modifié en fonction du Breaker Block et du déplacement pour chaque plage de temps
buySignal1 = ta.crossover(close[displacement1], lower1) and volume > volumeThreshold1 * averageVolume1
buySignal5 = ta.crossover(close[displacement5], lower5) and volume > volumeThreshold5 * averageVolume5
buySignal15 = ta.crossover(close[displacement15], lower15) and volume > volumeThreshold15 * averageVolume15
buySignal60 = ta.crossover(close[displacement60], lower60) and volume > volumeThreshold60 * averageVolume60
buySignal240 = ta.crossover(close[displacement240], lower240) and volume > volumeThreshold240 * averageVolume240

// Signal de vente modifié en fonction du Breaker Block et du déplacement pour chaque plage de temps
sellSignal1 = ta.crossunder(close[displacement1], upper1) and volume > volumeThreshold1 * averageVolume1
sellSignal5 = ta.crossunder(close[displacement5], upper5) and volume > volumeThreshold5 * averageVolume5
sellSignal15 = ta.crossunder(close[displacement15], upper15) and volume > volumeThreshold15 * averageVolume15
sellSignal60 = ta.crossunder(close[displacement60], upper60) and volume > volumeThreshold60 * averageVolume60
sellSignal240 = ta.crossunder(close[displacement240], upper240) and volume > volumeThreshold240 * averageVolume240


// Tracé des niveaux de limite de profit pour chaque plage de temps
hline(fibLevelInput1, color=color.green, linestyle=hline.style_dashed, title="Niveau de Limite de Profit 1 min")
hline(fibLevelInput5, color=color.green, linestyle=hline.style_dashed, title="Niveau de Limite de Profit 5 min")
hline(fibLevelInput15, color=color.green, linestyle=hline.style_dashed, title="Niveau de Limite de Profit 15 min")
hline(fibLevelInput60, color=color.green, linestyle=hline.style_dashed, title="Niveau de Limite de Profit 1 h")
hline(fibLevelInput240, color=color.green, linestyle=hline.style_dashed, title="Niveau de Limite de Profit 4 h")

// Définition des ordres de vente et d'achat pour chaque plage de temps
if buySignal1
    strategy.entry("Achat 1 min", strategy.long)
    
if sellSignal1
    strategy.entry("Vente 1 min", strategy.short)

if buySignal5
    strategy.entry("Achat 5 min", strategy.long)
    
if sellSignal5
    strategy.entry("Vente 5 min", strategy.short)

if buySignal15
    strategy.entry("Achat 15 min", strategy.long)
    
if sellSignal15
    strategy.entry("Vente 15 min", strategy.short)

if buySignal60
    strategy.entry("Achat 1 h", strategy.long)
    
if sellSignal60
    strategy.entry("Vente 1 h", strategy.short)

if buySignal240
    strategy.entry("Achat 4 h", strategy.long)
    
if sellSignal240
    strategy.entry("Vente 4 h", strategy.short)

// Configuration des ordres de sortie (Take Profit) pour chaque plage de temps
profitRatio = 2
stopLossRatio = 1

stopLossLevel1 = strategy.position_avg_price * (1 - stopLossRatio / (stopLossRatio + profitRatio))
stopLossLevel5 = strategy.position_avg_price * (1 - stopLossRatio / (stopLossRatio + profitRatio))
stopLossLevel15 = strategy.position_avg_price * (1 - stopLossRatio / (stopLossRatio + profitRatio))
stopLossLevel60 = strategy.position_avg_price * (1 - stopLossRatio / (stopLossRatio + profitRatio))
stopLossLevel240 = strategy.position_avg_price * (1 - stopLossRatio / (stopLossRatio + profitRatio))

strategy.exit("Stop Loss 1 min", "Achat 1 min", stop=stopLossLevel1)
strategy.exit("Stop Loss 1 min", "Vente 1 min", stop=stopLossLevel1)

strategy.exit("Stop Loss 5 min", "Achat 5 min", stop=stopLossLevel5)
strategy.exit("Stop Loss 5 min", "Vente 5 min", stop=stopLossLevel5)

strategy.exit("Stop Loss 15 min", "Achat 15 min", stop=stopLossLevel15)
strategy.exit("Stop Loss 15 min", "Vente 15 min", stop=stopLossLevel15)

strategy.exit("Stop Loss 1 h", "Achat 1 h", stop=stopLossLevel60)
strategy.exit("Stop Loss 1 h", "Vente 1 h", stop=stopLossLevel60)

더 많은