ブレイクアウトフラクタル戦略


作成日: 2023-12-19 15:32:57 最終変更日: 2023-12-19 15:32:57
コピー: 2 クリック数: 885
1
フォロー
1621
フォロワー

ブレイクアウトフラクタル戦略

概要

この戦略は,価格の動向を判断する長線トレンド追跡戦略である.これは,歴史的な価格の分岐点を計算し,最後の分岐点の突破を判断して,ポジションを決定する.同時に,それは,最後のNの分岐点の平均価格を計算して,トレンドの方向を判断し,トレンドが逆転したとき平仓する.

戦略原則

  1. 価格の分岐点を計算する.分岐点は,その日の最高価格が前2日と後2日の最高価格より高いと定義される.
  2. 最後の分岐点の価格を抵抗として記録する.
  3. 閉じる価格が最後の分岐点を突破すると,抵抗が突破されたと考え,多ポジションを確立する.
  4. 最後のNの分岐点の平均価格を計算してトレンドを判断する.平均価格が上昇する時は看板トレンド,下降する時は看板トレンドである.
  5. 複数のポジションを取ったとき,平均分岐点価格が下落に転じると平仓である.

優位分析

この分岐点に基づくトレンド判断策の最大の優点は,市場騒音を効率的にフィルターして,より長線のトレンド方向を判断できる点である.単純移動平均などの指標と比較して,突発的な異常波動に対する抵抗力が強い点である.

また,この戦略は,ポジション構築とポジションの基準を明確に判断し,頻繁な取引の問題が発生しません. これは,長線保有に特に適しています.

リスク分析

この策の最大のリスクは,分岐点自体の判断の確率性にある.分岐点は,価格が必ず逆転することを100%予測できない.つまり,誤った判断の確率は残っている.誤った判断が発生した場合,損失のリスクに直面する.

また,分岐点判断の時間帯が長いため,高周波取引には適さない.短線取引を追求する場合は,この戦略もあまり適さない.

最適化の方向

断面点判断の誤差確率を考慮して,以下の方法で最適化できます.

  1. ブリンライン通路,移動平均などの他の指標の確認と組み合わせて,単一の分形点判断誤りを避ける.

  2. 分形点のパラメータ,判断の前後周期の数など,分形点の判断を最適化するために調整する.

  3. 損失が一定程度に拡大したときに止まる.

要約する

この突破型分型策略は,全体として,長線トレンドを判断するのに非常に適しており,長線投資家が使用するのに非常に適しています. 判断の正確性を保証する前提で,パラメータを適切に調整し,他のフィルタリング指標を追加することで,この策略を大幅に最適化し,定量化決定の重要な構成要素にすることができます.

ストラテジーソースコード
/*backtest
start: 2023-11-18 00:00:00
end: 2023-12-18 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("Fractal Breakout Strategy (by ChartArt)", shorttitle="CA_-_Fractal_Breakout_Strat", overlay=true)

// ChartArt's Fractal Breakout Strategy
//
// Version 1.0
// Idea by ChartArt on April 24, 2016.
//
// This long only strategy determines the last fractal top
// and enters a trade when the price breaks above the last
// fractal top. The strategy also calculates the average
// price of the last 2 (or 3) fractal tops to get the trend.
//
// The strategy exits the long trade when the average of the
// fractal tops is falling (when the trend is lower highs).
// And the user can manually set a delay of this exit.
//
// In addition the fractals tops can be colored in blue
// and a line can be drawn based on the fractal tops.
// This fractal top line is colored by the fractal trend.
//
// List of my work: 
// https://www.tradingview.com/u/ChartArt/
// 
//  __             __  ___       __  ___ 
// /  ` |__|  /\  |__)  |   /\  |__)  |  
// \__, |  | /~~\ |  \  |  /~~\ |  \  |  
// 
// 


// input

n_time = input(title='Always exit each trade after this amount of bars later (Most important strategy setting)', defval=3)
price = input(hl2,title='Price type to determine the last fractal top and the fractal breakout, the default is (high+low)/2')


// fractal calculation

fractal_top = high[2] > high[3] and high[2] > high[4] and high[2] > high[1] and high[2] > high[0]
fractal_price = valuewhen(fractal_top, price, 1)
use_longer_average = input(true,title='Use Fractal price average of the last 3 fractals instead of the last 2 fractals?')
fractal_average = use_longer_average?(fractal_price[1] + fractal_price[2] + fractal_price[3] ) / 3 : (fractal_price[1] + fractal_price[2]) / 2
fractal_trend = fractal_average[0] > fractal_average[1]
no_repainting = input(true,title='Use the price of the last bar to prevent repainting?')
fractal_breakout = no_repainting?price[1] > fractal_price[0]:price[0] > fractal_price[0]


// highlight fractal tops

show_highlight = input(true,title='Highlight fractal tops in blue and color all other bars in gray?')
highlight = fractal_top?blue:silver
barcolor(show_highlight?highlight:na,offset=-2)
show_fractal_top_line = input(true,title='Draw a colored line based on the fractal tops?')
fractal_top_line = change(fractal_top) != 0 ? price : na
fractal_top_line_color = change(fractal_price) > 0 and fractal_breakout == true ? green : change(fractal_price) < 0 and fractal_breakout == false ? red : blue
plot(show_fractal_top_line?fractal_top_line:na,offset=-2,color=fractal_top_line_color,linewidth=4)


// strategy

trade_entry = fractal_trend and fractal_breakout
trade_exit = fractal_trend[n_time] and fractal_trend == false 
 
if (trade_entry)
    strategy.entry('Long', strategy.long)
 
if (trade_exit)
    strategy.close('Long')