골든 섹션 밴드 진동 전략


생성 날짜: 2023-11-21 13:47:12 마지막으로 수정됨: 2023-11-21 13:47:12
복사: 0 클릭수: 627
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

골든 섹션 밴드 진동 전략

개요

골드분할파동동이동전략은 골드분열이론에 기초한 기량화전략이다. 이전략은 주로 골드분열법을 이용한 여러 가격대를 계산하여 상하파동이동을 형성한다. 가격이 파동이동을 돌파할 때 거래 신호를 생성하고, 가격이동이동의 특징을 포착하여 수익을 창출한다.

전략 원칙

코드의 핵심적인 논리는 가격의 금분파를 계산하는 데에 있습니다. 주요 단계는 다음과 같습니다:

  1. 14주기 EMA 평균선을 중간축으로 계산
  2. ATR와 골드분배 비율에 따라 계산된 상단 4개의 파도 라인
  3. 거래 신호는 가격이 하향으로 하향을 돌파하거나 하향으로 상승을 돌파할 때 생성됩니다.
  4. 스톱로스트를 설정하여 가격 변동을 추적하고 수익을 얻습니다.

이러한 요점 기반의 접근 방식은 시장의 단기 변동을 효과적으로 포착하여 파동 사이를 돌아다니며 거래 수익을 창출합니다.

전략적 이점

이 전략의 가장 큰 장점은 금분할이라는 중요한 이론적 지표를 사용하여 중요한 가격 지점을 위치시켜 수익을 올리는 확률을 높이는 데 있습니다. 구체적인 장점은 주로 다음과 같습니다.

  1. 골드 분할파는 명확하고, 돌파구를 판단하기 쉽다.
  2. 적당한 범위, 너무 세세한 것도 아니고 너무 느슨한 것도 아니고
  3. 공격적인 거래와 보수적인 거래의 다양한 영역을 선택할 수 있습니다.
  4. 파장 흔들림 특징이 분명하고, 짧은 선 조작 전략이 효과가 있다.

전략적 위험

이 전략은 단기 수익을 추구하기 때문에 몇 가지 위험도 있습니다.

  1. 큰 주기적 추세에서는 수익을 낼 수 없습니다.
  2. 가격의 급격한 변동으로 인해 손실 위험이 커집니다.
  3. “이런 일이 벌어진다면, 우리는 더 많은 돌파구를 찾을 수 있을 것이다.
  4. 파장 진동 특징이 사라지면 무효

이러한 위험을 조절할 수 있는 방법은 적절한 변수를 조정하고, 적절한 파급대와 자금 관리를 선택하는 것이다.

전략 최적화

이 전략에는 더 많은 최적화 가능성이 있습니다:

  1. 트렌드 지표 필터링과 결합하여 특정 트렌드 방향에서 신호를 생성합니다.
  2. 특정 시간 동안 또는 중요한 이벤트 포인트 전에 정책을 종료합니다.
  3. 동적으로 시장의 변동 빈도에 맞게 중지량을 조정합니다.
  4. 최적화 변수: 다른 주기적 EMA를 기준 중선으로 선택함

요약하다

금분리파동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동동

전략 소스 코드
/*backtest
start: 2022-11-14 00:00:00
end: 2023-11-20 00:00:00
period: 1d
basePeriod: 1h
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/
// © drhakankilic

//@version=5
strategy("FIBONACCI BANDS Strategy", shorttitle="FBANDS Strategy", overlay=true)
// === Date === { 
//Backtest dates
fromDay = input.int(defval=1, title='From Day',minval=1,maxval=31)
fromMonth = input.int(defval=2, title='From Month',minval=1,maxval=12)
fromYear = input.int(defval=2022, title='From Year')
thruDay = input.int(defval=1, title='Thru Day',minval=1,maxval=31)
thruMonth = input.int(defval=1, title='Thru Month',minval=1,maxval=12)
thruYear = input.int(defval=2112, title='Thru Year')
showDate = true  // input(defval=true, title="Show Date Range")
start = timestamp(fromYear, fromMonth, fromDay, 00, 00)  // backtest start window
finish = timestamp(thruYear, thruMonth, thruDay, 23, 59)  // backtest finish window
window() =>  // create function "within window of time"
    time >= start and time <= finish ? true : false
// }

// === Long or Short ===  
tradeDirection = input.string(title="Long veya Short", options=["Long", "Short", "Both"], defval="Both",                                       group="Bot")
// Translate input into trading conditions
longOK  = (tradeDirection == "Long") or (tradeDirection == "Both")
shortOK = (tradeDirection == "Short") or (tradeDirection == "Both")
copypaste   = input('{{strategy.order.alert_message}}',         title='alert message to copy/paste',                                    group="Bot")
// }

// === FIBONACCI BANDS === {
EMAperiod = input.int(14, title='EMAperiod', minval=1, maxval=500, group="Fibonacci")
ATRperiod = input.int(14, title='ATRperiod', minval=1, maxval=500, group="Fibonacci")
EMA = ta.ema(close, EMAperiod)
TR1 = math.max(high - low, math.abs(high - close[1]))
TR = math.max(TR1, math.abs(low - close[1]))
ATR = ta.sma(TR, ATRperiod)
F2 = input(defval=1.618, title='Fibonacci Ratio 2', group="Fibonacci")
F3 = input(defval=2.618, title='Fibonacci Ratio 3', group="Fibonacci")
F4 = input(defval=4.236, title='Fibonacci Ratio 4', group="Fibonacci")
R1 = ATR
R2 = ATR * F2
R3 = ATR * F3
R4 = ATR * F4
FIBOTOP4 = EMA + R4
FIBOTOP3 = EMA + R3
FIBOTOP2 = EMA + R2
FIBOTOP1 = EMA + R1
FIBOBOT1 = EMA - R1
FIBOBOT2 = EMA - R2
FIBOBOT3 = EMA - R3
FIBOBOT4 = EMA - R4
plot(FIBOTOP4[1], title='FIBOTOP4', linewidth=1, color=color.new(color.orange, 0))
plot(FIBOTOP3[1], title='FIBOTOP3', linewidth=1, color=color.new(color.aqua, 20))
plot(FIBOTOP2[1], title='FIBOTOP2', linewidth=1, color=color.new(color.gray, 40))
plot(FIBOTOP1[1], title='FIBOTOP1', linewidth=1, color=color.new(color.purple, 40))

plot(FIBOBOT1[1], title='FIBOBOT1', linewidth=1, color=color.new(color.green, 40))
plot(FIBOBOT2[1], title='FIBOBOT2', linewidth=1, color=color.new(color.yellow, 40))
plot(FIBOBOT3[1], title='FIBOBOT3', linewidth=1, color=color.new(color.blue, 20))
plot(FIBOBOT4[1], title='FIBOBOT4', linewidth=1, color=color.new(color.aqua, 0))
// plot(EMA[1], style=plot.style_cross, title='EMA', color=color.new(color.red, 0))

prefm = input.string(title="Fibo", options=["close>FIBOTOP4(orange)", "close>FIBOTOP3(aqua)","close>FIBOTOP2(gray)","close>FIBOTOP1(purple)", "Disable"] , defval="close>FIBOTOP1(purple)", group="Long")
_prefm = false 
if (prefm == "close>FIBOTOP4(orange)" )
    _prefm := close>FIBOTOP4[1]
    
if (prefm == "close>FIBOTOP3(aqua)" )
    _prefm := close>FIBOTOP3[1]

if (prefm == "close>FIBOTOP2(gray)" )
    _prefm := close>FIBOTOP2[1]
    
if (prefm == "close>FIBOTOP1(purple)" )
    _prefm := close>FIBOTOP2[1]
 
 
if (prefm == "Disable" )
    _prefm := low<low[1] or low>low[1]  
    
prefmS = input.string(title="Fibo", options=["close<FIBOBOT1(green)", "close<FIBOBOT2(yellow)", "close<FIBOBOT3(blue)", "close<FIBOBOT4(aqua)", "Disable"] , defval="close<FIBOBOT1(green)", group="Short")
_prefmS = false 
if (prefmS == "close<FIBOBOT1(green)" )
    _prefmS := close<FIBOBOT1[1]
  
if (prefmS == "close<FIBOBOT2(yellow)" )
    _prefmS := close<FIBOBOT2[1]

if (prefmS == "close<FIBOBOT3(blue)" )
    _prefmS := close<FIBOBOT3[1]
  
if (prefmS == "close<FIBOBOT4(aqua)" )
    _prefmS := close<FIBOBOT4[1]

if (prefmS == "Disable" )
    _prefmS := low<low[1] or low>low[1]  

// }

long2= _prefm 

short2= _prefmS
//

// === Bot Codes === { 
enterlong = input("Long Code", title='Long İlk Alım', group="Long Code")
entershort= input("Short Code", title='Short İlk Alım', group="Short Code")
exitlong = input("Long Exit Code", title='Long Exit', group="Long Code")
exitshort= input("Short Exit Code", title='Short Exit', group="Short Code")
// }

////////////////////////////////////////////////////////////////////////////////////////////TPSL
// Inputs
sl_inp = input.float(4, title='Stop %', step=0.1, group="Long") / 100
tp_inp = input.float(1.5, title='TP %', step=0.1, group="Long") / 100

sl_inp2 = input.float(4, title='Stop %', step=0.1, group="Short") / 100
tp_inp2 = input.float(1.5, title='TP %', step=0.1, group="Short") / 100

longtp = strategy.position_avg_price * (1 + tp_inp) 
longstop=  strategy.position_avg_price * (1 - sl_inp)

shortstop=  strategy.position_avg_price * (1 + sl_inp2)
shorttp = strategy.position_avg_price * (1 - tp_inp2) 
////////////////////////////////////////////////////////////////////////////////////////////
if window() and strategy.position_size==0 and longOK
    strategy.entry("Long", strategy.long, when= long2, alert_message=enterlong, comment="Long")
    
if strategy.position_size>0
    strategy.exit("Long", stop= longstop, limit=longtp, alert_message=exitlong, comment="TPSL")
////////////////////////////////////////////////////////////////////////////////////////////SHORT
if window() and strategy.position_size==0 and shortOK 
    strategy.entry("Short", strategy.short, when= short2, alert_message=entershort, comment="Short")
    
if strategy.position_size<0
    strategy.exit("Short", stop= shortstop, limit= shorttp, alert_message=exitshort, comment="TPSL")