戦略をフォローするハルフ移動平均傾向

作者: リン・ハーンチャオチャン, 日時: 2023-09-16 18:41:33
タグ:

概要

Hull移動平均トレンドフォロー戦略は,市場のトレンド方向を決定し,買い売りシグナルを生成するためにHull移動平均を利用する.中長期トレンドを捕捉し,トレンド開始の早期にポジションを確立し,トレンド逆転の前にポジションを閉じる.

原則

この戦略は,トレンド方向を決定するために,ハル移動平均と単純な移動平均の両方を使用する.短い期間のハルMAがより長い期間のハルMAを超えると,購入信号を生成する.短いHullMAがより長い期間の下を通ると,販売信号を生成する.

簡単な移動平均は,リアルタイムトレンド方向を決定する.短いEMAが長いEMAを上回ると,上昇傾向を示します.短いEMAが長いEMAを下回ると,下落傾向を示します.ハルMAとEMAのシグナルが上昇傾向または下落傾向に同意するときにのみ取引が行われます.

さらに,この戦略は,市場変動を測定し,統合取引を避けるためにK線ボディチャネルを使用する.価格がチャネル範囲を突破するときにのみ取引が考慮される.

利点

  • Hull MAは価格変化や初期トレンドシフトを検出する際にはより敏感です.

  • Hull MAと EMAの両方を使えば 誤った信号は消えます

  • K線チャネルは,横向市場での過剰な取引を避けます.

  • トレンドをフォローすることで トレンドが広がるにつれて 持続的な利益を得ることができます

リスク

  • 移動平均値は遅れがあり,最適なトレンド逆転入口点を逃す可能性があります.

  • 不正確な統合検出は,不良な取引を引き起こす可能性があります.

  • 取引頻度が低い場合 失敗する取引が大きな影響を与える.

  • 短期的な振動から利益を得られない

リスク管理

  • 適時なトレンド信号生成のために MA 期間を最適化する.

  • RSI や BBANDS などの他の指標を使って統合を決定する.

  • 攻撃的な資本管理を行い,取引に対する損失率を制限する.

  • 短期的な利益を活用するための他の戦略を補完します

概要

ハル移動平均トレンドフォロー戦略は,ハルMAとEMAの組み合わせによる中長期トレンドを効果的に追跡する.利益トレンドを通じて利益を蓄積し,逆転前に早く退出する.これは推奨に値するシンプルで実践的な量取引戦略である.


/*backtest
start: 2023-08-16 00:00:00
end: 2023-09-15 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2

// strategy(title='HULLMiguel 2019/ Strategy v3', shorttitle='HULLMiguel_2019_Strategy', overlay=true, pyramiding=0, default_qty_value=1000, initial_capital=1000, currency=currency.USD)

//Candle body resistance Channel-----------------------------//
len = 34
src = input(close, title="Candle body resistance Channel")
out = sma(src, len)
last8h = highest(close, 13)
lastl8 = lowest(close, 13)
bearish = cross(close,out) == 1 and falling(close, 1)
bullish = cross(close,out) == 1 and rising(close, 1)
channel2=input(false, title="Bar Channel On/Off")
ul2=plot(channel2?last8h:last8h==nz(last8h[1])?last8h:na, color=black, linewidth=1, style=linebr, title="Candle body resistance level top", offset=0)
ll2=plot(channel2?lastl8:lastl8==nz(lastl8[1])?lastl8:na, color=blue, linewidth=1, style=linebr, title="Candle body resistance level bottom", offset=0)
//fill(ul2, ll2, color=black, transp=95, title="Candle body resistance Channel")

//-----------------Support and Resistance 
RST = input(title='Support / Resistance length:',  defval=15) 
RSTT = valuewhen(high >= highest(high, RST), high, 0)
RSTB = valuewhen(low <= lowest(low, RST), low, 0)
RT2 = plot(RSTT, color=RSTT != RSTT[1] ? na : red, linewidth=1, offset=+0)
RB2 = plot(RSTB, color=RSTB != RSTB[1] ? na : green, linewidth=1, offset=0)

//--------------------Trend colour ema------------------------------------------------// 
src0 = close, len0 = input(13, minval=1, title="EMA 1")
ema0 = ema(src0, len0)
direction = rising(ema0, 2) ? +1 : falling(ema0, 2) ? -1 : 0
plot_color = direction > 0  ? lime: direction < 0 ? red : na
plot(ema0, title="EMA", style=line, linewidth=3, color = plot_color)

//-------------------- ema 2------------------------------------------------//
src02 = close, len02 = input(21, minval=1, title="EMA 2")
ema02 = ema(src02, len02)
direction2 = rising(ema02, 2) ? +1 : falling(ema02, 2) ? -1 : 0
plot_color2 = direction2 > 0  ? green: direction2 < 0 ? red : na
plot(ema02, title="EMA Signal 2", style=line, linewidth=2, color = plot_color2)

//=============Hull MA//
show_hma = input(false, title="Display Hull MA Set:")
hma_src = input(close, title="Hull MA's Source:")
hma_base_length = input(16, minval=1, title="Hull MA's Base Length:")
hma_length_scalar = input(10, minval=0, title="Hull MA's Length Scalar:")
hullma(src, length)=>wma(2*wma(src, length/2)-wma(src, length), round(sqrt(length)))
plot(not show_hma ? na : hullma(hma_src, hma_base_length+hma_length_scalar*6), color=black, linewidth=5, title="Hull MA")
dif_close_hull= (close-hullma(hma_src, hma_base_length+hma_length_scalar*6))/close
Percent_dif = (dif_close_hull/(hullma(hma_src, hma_base_length+hma_length_scalar*6)))
//direction3 = Percent_dif>0 ? +1 : Percent_dif<0 ? -1 : 0
//plot_color3 = direction3 > 0  ? lime: direction3 < 0 ? red : na
//plot(dif_close_hull, title="dif close hull", style=line, linewidth=6, color = plot_color3)

//============ signal Generator ==================================//
Piriod=input('720')
ch1 = security(syminfo.tickerid, Piriod, open)
ch2 = security(syminfo.tickerid, Piriod, close)
plot(ch1, title="EMA Signal 2", style=line, linewidth=1, color = blue)
//longCondition = crossover(security(tickerid, Piriod, close),security(tickerid, Piriod, open))
//plot((close-ema02)/ema02+close)
longCondition = direction > 0 and direction2> 0

if (longCondition)
    strategy.entry("BUY", strategy.long)
//shortCondition = crossunder(security(tickerid, Piriod, close),security(tickerid, Piriod, open))
shortCondition = direction < 0 and direction2 < 0

if (shortCondition)
    strategy.entry("SELL", strategy.short)

///////////////////////////////////////////////////////////////////////////////////////////

もっと