モメントトラッキング 双 EMA クロスオーバー 戦略

作者: リン・ハーンチャオチャン,日付: 2024-02-26 16:40:29
タグ:

img

概要

この戦略は,トレンドをフォローするアルゴリズム的な取引戦略である.異なるパラメータを持つ2つのEMAラインを計算し,二つのEMAの間にゴールデンクロスとデスクロスが発生するときに取引信号を生成する.この戦略は,利益出口のために複数のEMAラインを組み合わせ,リスクを制御するためにストップロストポイントを設定する.

戦略原則

この戦略は,4つの EMA ラインを使用し,高速 EMA とスロー EMA を含む.そのクロスオーバーは購入・販売信号を生成するために使用されます.また,高速 EMA とスロー EMA のパラメータを持つ2つの EMA ラインは,利益をロックするために,ポジションを部分または完全に前もって退出するために使用されます.

EMAは2番目の EMA線を越えた場合,または3番目の EMA線を越えた場合,戦略は選択的に部分またはすべてのポジションを退場する.EMAは2番目の EMA線を超えた場合,または3番目の EMA線を超えた場合,戦略は選択的にすべてのポジションを退場する.

さらに,この戦略は,過剰な損失を防ぐために,ロングとショートストップロスの両方を設定しています.特に,ロングポジションのストップロスはエントリー価格の6%とショートポジションの3%に設定されています.

利点分析

典型的な二重EMAクロスオーバー戦略と比較して,この戦略の主な利点は以下の通りである.

  1. 利益離脱のために複数の EMA ラインを設定することで,利益をよりうまく固定し,後続的な引き下げ中に利益の縮小を防ぐことができます.

  2. ショートポジションはストップ・ロスは小さいので,通常の市場の波動に耐えており,頻繁にストップ・ロスを防ぐことができます.

  3. EMA線を異なるパラメータで設定することで,市場状況に基づいて最適な出口点を選択できます.

  4. 全体戦略は,中期から長期の動向からより大きな利益を得るために,傾向を追跡する能力が良好です.

リスク分析

この戦略の主なリスクは以下のとおりです.

  1. レンジ・バインド市場では,EMA線によって生成される取引信号は頻繁であり,過剰取引につながる可能性があります.

  2. ショートストップ・ロスは,極端な市場状況を防ぐしかできず,戦略口座の大幅な引き下げを防ぐことはできません.

  3. 長期的調整によって利益は著しく減少する可能性があります.

  4. 戦略はパラメータ調節に敏感である.不正な設定は戦略の失敗を引き起こす可能性がある.

最適化

上記のリスクを考慮して,戦略は次の側面で最適化できます.

  1. マシン学習アルゴリズムを増やし,トレンド判断を助け,不正取引の確率を減らす.

  2. 適応性のあるストップロスのメカニズムを強化し,市場の変動に基づいてストップロスを動的に調整する.

  3. 過剰な資本占拠を避けるために資本利用を設定し,ポジション管理メカニズムを増やす.

  4. 明らかなトレンドと高い変動を持つ取引製品を選択する.

  5. パラメータ最適化モジュールを増やして パラメータの自動最適化と更新を実現する.

結論

総合的には,ダブルEMAクロスオーバー戦略は,コスト効率の良いトレンドフォロー戦略である.利益を得るために複数のEMAライン,小さなショートストップ,そして良いトレンドフォロー能力などの利点がある.しかし,この戦略にはまだいくつかのリスクがある.安定性を向上させるために,さらなるパラメータチューニング最適化と機械学習アルゴリズムの組み込みが必要である.一般的に,この戦略は,アルゴリズム取引を行うためにいくつかの取引経験を持つ投資家に適している.


/*backtest
start: 2023-02-19 00:00:00
end: 2024-02-25 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RealTraderAkeme

//@version=5
strategy("AKEME_EMA_CROSS_V6", overlay=true)

////////////////////////////////////////////////////////////PARAMETERS/////////////////////////////////////////////////////////////////
emaFast_op = input(title="Fast_EMA", defval=6)
emaSlow_op = input(title="Slow_EMA", defval=26)
emaExit_op = input(title="Sell_EMA_Exit",defval=10)
emabuyExit_op = input(title="Buy_EMA_Exit",defval=20)
Order_Value = input(defval=1000, title="Order_Value in Pounds") 
Direction_Of_Trade = input(title="Trade Direction", defval="Both")


////////////////////////////////////////////////////////////INPUTS//////////////////////////////////////////////////////////////////

fastEMA = ta.ema(close, emaFast_op)
slowEMA = ta.ema(close,emaSlow_op)
emaExit = ta.ema(close,emaExit_op)
emabuyExit = ta.ema(close,emabuyExit_op)
Entry_Ratio = strategy.openprofit/Order_Value


//////////////////////////////////////////////////////////GRAPHS//////////////////////////////////////////////////////////////////

plot(fastEMA, color=color.orange, linewidth = 2)
plot(slowEMA,color = color.blue, linewidth = 2)
plot(emaExit,color = color.gray, linewidth = 2)
plot(series=emabuyExit, color= color.rgb(210, 74, 235), linewidth=2)


/////////////////////////////////////////////////////Conditions//////////////////////////////////////////////////////////////////////
longOK  = (Direction_Of_Trade == "Long") or (Direction_Of_Trade == "Both")
shortOK = (Direction_Of_Trade == "Short") or (Direction_Of_Trade == "Both")


///////////////////////////////////////////////////////////ENTRIES&EXITS///////////////////////////////////////////////////////////////
longCondition = ta.crossover(fastEMA, slowEMA) and longOK 
if (longCondition)  
    strategy.entry("Buy", strategy.long) 

shortCondition = ta.crossunder(fastEMA, slowEMA) and shortOK
if (shortCondition)
    strategy.entry("Sell", strategy.short)

if (strategy.position_size > 0 and shortCondition)
    strategy.exit(id="exit Buy", stop=close)
    
if (strategy.position_size < 0 and longCondition)
    strategy.exit(id="exit Sell", stop=close)


/////////////////////////////////////////////////////TAKE PROFIT CONDITIONS////////////////////////////////////////////////////////

if  ta.crossunder(fastEMA, emabuyExit) and Entry_Ratio > 0.08333
    strategy.close("Buy",comment = "Exit")

if  ta.crossover(fastEMA, emaExit) and Entry_Ratio > 0.016666
    strategy.close("Sell",comment = "Exit")


if Entry_Ratio > 0.4166666 //0.4166666 
    strategy.close("Buy",comment = "Exit", qty_percent = 100)

if Entry_Ratio > 0.0833333//0.0833333
    strategy.close("Sell",comment = "Exit")//50

if Entry_Ratio > 0.1111111//4000
    strategy.close("Sell",comment = "Exit", qty_percent = 50)

if ta.crossover(fastEMA, emaExit) and Entry_Ratio > 0.278 //Percentage 
    strategy.close("Sell",comment = "Exit")

////////////////////////////////////////////STOP LOSS AS PERCENTAGE OF ENTRY CONDITIONS///////////////////////////////////////////

if Entry_Ratio < -0.05555555555
    strategy.close("Buy",comment = "Exit")
if Entry_Ratio < -0.027777777777
    strategy.close("Sell",comment = "Exit")// The Sell Stoloss is half the buying stoploss.



もっと