黄金分割バンド振動戦略


作成日: 2023-11-21 13:47:12 最終変更日: 2023-11-21 13:47:12
コピー: 0 クリック数: 628
1
フォロー
1621
フォロワー

黄金分割バンド振動戦略

概要

ゴールド分割波段振動戦略は,ゴールド分割理論に基づいて設計された量化戦略である.この戦略は,主にゴールド分割法を利用して複数の価格帯を計算し,上下波段を形成する.価格が波段を破るとき取引信号を生成し,波段間の価格振動の特徴をキャプチャすることによって利益を上げる.

戦略原則

コードの核心的な論理は,価格の黄金の分割波段を計算する上で鍵となる点である.主なステップは:

  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")