10EMAダブルクロスオーバートレンドフォロー戦略


作成日: 2023-12-29 16:03:55 最終変更日: 2023-12-29 16:03:55
コピー: 1 クリック数: 807
1
フォロー
1621
フォロワー

10EMAダブルクロスオーバートレンドフォロー戦略

概要

この戦略は,10EMAと50EMAのダブルクロスに基づいたトレンド追跡戦略である.これは,時計線の10EMAを補助判断として組み合わせて,牛と熊が交替する市場で動的にトレンドの方向を見つけ,自動でストロップを追跡する.

戦略原則

戦略の核心的な論理は,10EMAと50EMAの金叉死叉に基づいています.具体的には,10EMAが上から50EMAを金叉形成すると,市場が上昇傾向に入ると判断し,10EMAが上から下から50EMAを死叉形成すると,市場が下行傾向に入ると判断する.

金叉死叉後の1-5根K線内での多空を行う.さらに,戦略は,時線の10EMAを補助判断として導入し,時線の10EMAが上昇傾向にあるときのみ金叉の後で多ポジションを開く.時線の10EMAが下降傾向にあるときのみ,時線の10EMAが死叉の後で空置を開く.それによって,部分的な偽信号をフィルターする.

ポジション開設後,ストップ+ストップを追跡する出口を戦略で採用する.ストップを追跡することで,利益をロックし,取引の利益を最大限に確保できる.ストップは,価格がターゲットに達したときにポジションを閉鎖して利益を確保する.

戦略的優位性

この戦略の最大の利点は,EMAの交差を利用して主要トレンドの方向を判断すると同時に,補助指標のフィルタリング信号を導入することで,偽交差を効果的にフィルタリングして信号の信頼性を向上させることが可能である.さらに,ダブルEMAの交差は,トラッキングストップと制限価格のストップを組み合わせて,トレンドの利益を最大化し,取引リスクを効果的に制御し,全体のリスクと利益の良好な比率をもたらす.

この戦略は,単一の指標戦略よりもトレンドの方向と幅度をより正確に判断できます.従来のストップ・ストップと比較して,この戦略は,より高度なトラッキング・ストップ・ストップ技術を使用して,利益をより正確にロックできます.

リスク分析

この戦略は,主に中断的なウィップソーとトレンドの逆転のリスクに直面しています. 連続した偽のクロスシグナルが発生すると,戦略がブレイクされる可能性があります. さらに,ポジション開設後に価格の逆転も損失を生じます.

ウィップソーのリスクを下げるために,戦略は補助指標を添加して信号フィルタリングを行う.トレンドの逆転のリスクを制御するために,戦略は,より寛容なストップ範囲を採用し,価格の制限ストップの設定も,そのようなリスクを減らすのに役立ちます.ストップが誘発された場合,トレンドの方向に戻ることを考慮することもできます.

最適化の方向

この戦略にはいくつかの最適化方向があります.第一に,EMA周期,開場遅延根数などの異なるパラメータの組み合わせをテストして最適なパラメータを探し出すことができます.第二に,MACD,BOLLなどのシグナルフィルタリングを導入して,シグナル品質を向上させることができます.第三に,時間ストップ,振動ストップなどのストップロジックを最適化することができます.第四に,特定の時間帯または上昇下降の下でのみシグナルをトリガーするなど,より多くの状況に合わせて戦略を起動することができます.

要約する

10EMAダブルクロストレンド追跡戦略は,EMAゴールドクロスとデスクロスによって現在のトレンドの方向を判断し,トラッキングストップと制限ストップを設定して利益をロックし,リスクを制御し,補助指標のフィルタリング信号と組み合わせて信号の質を向上させることで,より完全なトレンド取引戦略です.単一の指標と伝統的なストップストップの優位性を持つこの戦略は,判断精度,ストップストップの最適化などの優位性があり,トレンドの利益を効果的に獲得できる同時リスク制御の戦略です.もちろん,この戦略には改善の余地があり,パラメータ最適化,より多くの補助指標などの追加により戦略のパフォーマンスをさらに強化できます.

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

//@version=5
strategy("10ema Strat 9", overlay=true, format=format.price)
//#region // inputs for candles
//time
t1 = time(timeframe.period,"0930-1500") //last hour of market is not ideal for trading
// candle status
bullish = close > open and barstate.isconfirmed
bearish = open > close and barstate.isconfirmed
bullcandle = ta.valuewhen(bullish, close, 0)
bearcandle = ta.valuewhen(bearish, close, 0)
ema1 = input.int(10, minval=1, title="short ema")
ema2 = input.int(50, minval=1, title="long ema")
ema3 = input.int(200, minval=1, title="hourly 10 ema")
//@variable Input for source
src = input(close, title="Source")
offsetema = input.int(title="Offset", defval=0, minval=-500, maxval=500)
sema = ta.ema(src, ema1)//@variable Input for smaller ema1
lema = ta.ema(src, ema2)//@variable Input for longer ema2
hema = ta.ema(src, ema3)// @variable Input for hourly ema3
bullcrosscount = ta.barssince(ta.crossover(sema,lema)) //@variable Input 10/50 cross higher
bearcrosscount = ta.barssince(ta.crossunder(sema,lema)) //@variable Input 10/50 cross lower
ideallong = bullcrosscount <= 5 //number of candles after the cross
idealshort = bearcrosscount <= 5 //number of candles after the cross

emabull = (sema > lema) and bearish and close > sema and close > hema and ideallong and t1 and barstate.isconfirmed
xemabull = ta.barssince(emabull)
dbullema = emabull and emabull[1] and xemabull <=1
bullentry = if dbullema
    ta.valuewhen(emabull[1], high + 0.05, 0)
else 
    ta.valuewhen(emabull, high + 0.05, 0)
bullentryh = dbullema ? bullentry[1] : bullentry
bullentrylow = ta.valuewhen(emabull, low - 0.05, 0)
bullstop = (bullentryh - bullentrylow) <= 1.00 ? bullentryh - 1.00 : (bullentryh - bullentrylow) <= 10.40 ? bullentrylow : na
bulltarget = (bullentryh - bullstop) * 1.62 + bullentryh

// bear setup
emabear = (sema < lema) and bullish and close < sema and close < hema and idealshort and t1 and barstate.isconfirmed
xemabear = ta.barssince(emabear)
dbearema = emabear and emabear [1] and xemabear <=1
bearentry = if dbearema
    ta.valuewhen(emabear[1], low - 0.05, 0)
else
    ta.valuewhen(emabear, low - 0.05, 0)
bearentryh = dbearema ? bearentry[1] : bearentry
bearentryhigh = ta.valuewhen(emabear, high + 0.05, 0)
bearstop = (bearentryhigh - bearentryh) <= 1.00 ? bearentryh + 1.00 : (bearentryh - bearentryhigh) <= 10.40 ? bearentryhigh : na
beartarget = bearentryh - (bearstop-bearentryh) * 1.62

bullclose = (xemabull <=7) and bullish and bullcrosscount >=1 and barstate.isconfirmed //number of candles for a close above
bearclose = (xemabear <=7) and bearish and bearcrosscount >=1 and barstate.isconfirmed //number of candles for a close below
buyzone = ta.barssince(bullclose)
shortzone =  ta.barssince(bearclose)
idealbuy = close >= bullentryh and bullclose and (buyzone<=7)
idealsell = close <= bearentryh and bearclose and (shortzone<=7)

// // bull setup on chart
// if sema > lema and xemabull < 50
//     var line line_bullentry = line.new(bar_index, na, bar_index + 1, na, color=color.rgb(0, 200, 0), style=line.style_solid, width=1)
//     if emabull
//         line.set_xy1(line_bullentry, x=bar_index, y=bullentryh)
//         line.set_xy2(line_bullentry, x=bar_index, y=bullentryh)
//         alert("EMA-bullish", alert.freq_once_per_bar_close)
//     line.set_x2(line_bullentry, x=bar_index)
//     var line line_bullstop = line.new(bar_index, na, bar_index + 1, na, color=color.rgb(250, 0, 0), style=line.style_solid, width=1)
//     if emabull
//         line.set_xy1(line_bullstop, x=bar_index, y=bullstop)
//         line.set_xy2(line_bullstop, x=bar_index, y=bullstop)
//     line.set_x2(line_bullstop, x=bar_index)    
//     var line line_bulltarget = line.new(bar_index, na, bar_index + 1, na, color=color.rgb(200, 100, 200), style=line.style_solid, width=1)
//     if emabull
//         line.set_xy1(line_bulltarget, x=bar_index, y=bulltarget)
//         line.set_xy2(line_bulltarget, x=bar_index, y=bulltarget)
//     line.set_x2(line_bulltarget, x=bar_index)

// //bear setup on chart
// if sema < lema and xemabear < 50
//     var line line_bearentry = line.new(bar_index, na, bar_index, na, color=color.rgb(0, 200, 0), style=line.style_solid, width=1)
//     if emabear
//         line.set_xy1(line_bearentry, x=bar_index, y=bearentryh)
//         line.set_xy2(line_bearentry, x=bar_index, y=bearentryh)
//         alert("EMA-bearish", alert.freq_once_per_bar_close)
//     line.set_x2(line_bearentry, x=bar_index)
//     var line line_bearstop = line.new(bar_index, na, bar_index, na, color=color.rgb(250, 0, 0), style=line.style_solid, width=1)
//     if emabear
//         line.set_xy1(line_bearstop, x=bar_index, y=bearstop)
//         line.set_xy2(line_bearstop, x=bar_index, y=bearstop)
//     line.set_x2(line_bearstop, x=bar_index)
//     var line line_beartarget = line.new(bar_index, na, bar_index, na, color=color.rgb(200, 100, 200), style=line.style_solid, width=1)
//     if emabear
//         line.set_xy1(line_beartarget, x=bar_index, y=beartarget)
//         line.set_xy2(line_beartarget, x=bar_index, y=beartarget)
//     line.set_x2(line_beartarget, x=bar_index)

//#endregion
//execution 
if idealbuy
    strategy.close("sell", comment=na)	
    strategy.entry("buy", strategy.long, limit=bullentryh, stop=bullstop, comment="buy")
strategy.exit("exit","buy", trail_points = low, trail_offset = 5, qty_percent=100, limit=bulltarget, stop=bullstop)

if idealsell
	strategy.close("buy",comment=na)
    strategy.entry("sell", strategy.short, limit=bearentryh, stop=bearstop, comment="sell")
strategy.exit("exit","sell", trail_points = low, trail_offset = 5, qty_percent=100, limit=beartarget, stop=bearstop)
// strategy.close_all(time == close_day) 
//#region // graphical analysis
//Plots
plotshape(emabull, location=location.belowbar, title='emabull')
plotshape(idealbuy, style=shape.circle, color=color.green, title="bull close")
plotshape(emabear, title='emabear')
plotshape(idealsell, location=location.belowbar, style=shape.circle, color=color.red, title="bear close")

// //Dashboard
// var label id = na
// label.delete(id)   // Delete last label
// i_offsetLabel = input(15, "Data Dashboard Offset") 
// offset = i_offsetLabel * (time - time[1])
// dynamicText = "= Bull Setup ="
// id := label.new(x=time + offset, y=open, xloc=xloc.bar_time, text=dynamicText, color=color.rgb(255, 255, 255), size=size.normal)
// label.set_textcolor(id, color.rgb(0, 0, 0))
// label.set_text(id=id, text=dynamicText)
// label.set_textalign(id, text.align_left)
// label.set_text(id=id, text=dynamicText)
// f_round( _val, _decimals) => 
//     _p = math.pow(10, _decimals)
//     math.round(math.abs(_val) * _p) / _p * math.sign(_val)
// dynamicText := dynamicText + "\n" + str.tostring(f_round(bulltarget,2)) + "  :Target"
// label.set_text(id=id, text=dynamicText)
// dynamicText := dynamicText + "\n" + str.tostring(f_round(bullentryh,2)) + "  :Entry"
// label.set_text(id=id, text=dynamicText)
// dynamicText := dynamicText + "\n" + str.tostring(f_round(bullstop,2)) + "  :Stop"
// label.set_text(id=id, text=dynamicText)
// dynamicText := dynamicText + "\n"
// label.set_text(id=id, text=dynamicText)
// dynamicText := dynamicText + "\n" + "= Bear Setup ="
// label.set_text(id=id, text=dynamicText)
// dynamicText := dynamicText + "\n" + str.tostring(f_round(bearstop,2)) + "  :Stop"
// label.set_text(id=id, text=dynamicText)
// dynamicText := dynamicText + "\n" + str.tostring(f_round(bearentryh,2)) + "  :Entry"
// label.set_text(id=id, text=dynamicText)
// dynamicText := dynamicText + "\n" + str.tostring(f_round(beartarget,2)) + "  :Target"
// label.set_text(id=id, text=dynamicText)
// //#endregion