4つの指標のモメンタム逆転戦略

作者: リン・ハーンチャオチャン開催日:2023年11月27日 15:51:01
タグ:

img

概要

この戦略は,EMAクロスオーバーやRSIとCCIの過売/過買い値で確認されたさらなるエントリーを通じて価格動向を特定するために,移動平均EMA,相対強度指数RSIおよびコモディティチャネル指数CCIの3つの主要な技術指標を使用します.この中期取引戦略は,動向の逆転を把握することを目的としています.

戦略の論理

  1. 価格の動向を決定するために4期間のEMAと8期間のEMAのクロスオーバーを使用します.

  2. EMAが上向きになる時,つまり4期EMAが8期EMAを超えると,RSI (65以上) とCCI (0以上) がオーバー買いされてないことを確認し,ロング信号を発します.

  3. EMAが下向きに回る時,つまり4期EMAが8期EMAを下回る時,RSI (35未満) とCCI (0以下) が過売れていることを確認してショート信号を出す.

  4. ストップ・ロスを設定し,トレード・シグナルが発信されると,入力距離に基づいて利益率を設定します.

要するに,この戦略は,中期トレンドと短期間の過剰購入/過剰売却レベルを比較的安定した信号として考慮し,ストップ損失と利益を取ることで,取引毎の損失を効果的に制限します.

利点分析

  1. 複数のインジケーターは,個々のオシレーターからの偽信号を緩和する.

  2. EMAは主要な傾向を決定し,RSIとCCIは勝率を改善するために過熱区域を避ける.

  3. 自動ストップ・ロストとテイク・プロフィット設定は,極端な動きで損失を制限します.

  4. 純粋に技術的な性質により この戦略は 任意の時間枠で 簡単に実行できます

リスク分析

  1. 重要な基本的なニュースは技術レベルを上回る可能性があります

  2. ストップ・ロスは大きな波動性によるより広いストップ・コールによって引き上げられる.

  3. 頻繁な取引により取引コストが高くなり,高周波アルゴリズムに任せるのが最善です.

増進 の 機会

  1. マシン・ラーニングモデルを組み込み 基本に基づいてパラメータを自動調整する

  2. 固定距離ではなく 変動に反応する 適応式ストップを構築します

結論

この多面的な戦略は,最適化されたパラメータの下で一貫した中期利益をもたらし,アクセス可能な技術システムになります.それでも,継続的な改良のための領域を提示する拡張ストップなどを通じてブラック・スワンイベントに許容が必要です.


/*backtest
start: 2023-11-19 00:00:00
end: 2023-11-26 00:00:00
period: 45m
basePeriod: 5m
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/
// © SoftKill21

//@version=4


strategy(title="Moving Average Exponential", shorttitle="EMA", overlay=true)


len4 = input(4, minval=1, title="Length_MA4")
src4 = input(close, title="Source")
offset4 = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500)
out4 = ema(src4, len4)
plot(out4, title="EMA", color=color.blue, offset=offset4)

len8 = input(8, minval=1, title="Length_MA8")
src8 = input(close, title="Source")
offset8 = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500)
out8 = ema(src8, len8)
plot(out8, title="EMA", color=color.blue, offset=offset8)


//rsioma
src = close, len = input(14, minval=1, title="Length")
up = rma(max(change(ema(src, len)), 0), len)
down = rma(-min(change(ema(src, len)), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
//plot(rsi, color=color.blue)
//band1 = hline(80)
//band0 = hline(20)
//fill(band1, band0, color=color.purple, transp=90)
//hline(50, color=color.gray, linestyle=plot.style_line)
sig = ema(rsi, 21)
//plot(sig, color=color.purple)

//woodie
cciTurboLength = input(title="CCI Turbo Length", type=input.integer, defval=6, minval=3, maxval=14)
cci14Length = input(title="CCI 14 Length", type=input.integer, defval=14, minval=7, maxval=20)

source = close

cciTurbo = cci(source, cciTurboLength)
cci14 = cci(source, cci14Length)

last5IsDown = cci14[5] < 0 and cci14[4] < 0 and cci14[3] < 0 and cci14[2] < 0 and cci14[1] < 0
last5IsUp = cci14[5] > 0 and cci14[4] > 0 and cci14[3] > 0 and cci14[2] > 0 and cci14[1] > 0
histogramColor = last5IsUp ? color.green : last5IsDown ? color.red : cci14 < 0 ? color.green : color.red


// Exit Condition
// Exit Condition
a = input(12)*10
b = input(15)*10
c = a*syminfo.mintick
d = b*syminfo.mintick


longCondition = crossover(out4, out8) and (rsi >= 65 and cci14>=0)
shortCondition = crossunder(out4, out8) and (rsi <=35 and cci14<=0)


long_stop_level     = float(na)
long_profit_level1  = float(na)
long_profit_level2  = float(na)
long_even_level     = float(na)

short_stop_level    = float(na)
short_profit_level1 = float(na)
short_profit_level2 = float(na)
short_even_level    = float(na)

long_stop_level     := longCondition  ? close - c : long_stop_level     [1]
long_profit_level1  := longCondition  ? close + d : long_profit_level1  [1]
//long_profit_level2  := longCondition  ? close + d : long_profit_level2  [1]
//long_even_level     := longCondition  ? close + 0 : long_even_level     [1]

short_stop_level    := shortCondition ? close + c : short_stop_level    [1]
short_profit_level1 := shortCondition ? close - d : short_profit_level1 [1]
//short_profit_level2 := shortCondition ? close - d : short_profit_level2 [1]
//short_even_level    := shortCondition ? close + 0 : short_even_level    [1] 


//ha
// === Input ===
//ma1_len = input(1, title="MA 01")
//ma2_len = input(40, title="MA 02")

// === MA 01 Filter ===
//o=ema(open,ma1_len)
//cc=ema(close,ma1_len)
//h=ema(high,ma1_len)
//l=ema(low,ma1_len)

// === HA calculator ===
//ha_t = heikinashi(syminfo.tickerid)
//ha_o = security(ha_t, timeframe.period, o)
//ha_c = security(ha_t, timeframe.period, cc)
//ha_h = security(ha_t, timeframe.period, h)
//ha_l = security(ha_t, timeframe.period, l)

// === MA 02 Filter ===
//o2=ema(ha_o, ma2_len)
//c2=ema(ha_c, ma2_len)
//h2=ema(ha_h, ma2_len)
//l2=ema(ha_l, ma2_len)

// === Color def ===
//ha_col=o2>c2 ? color.red : color.lime

// ===  PLOTITING===
//plotcandle(o2, h2, l2, c2, title="HA Smoothed", color=ha_col)

tp=input(120)
sl=input(96)
    
strategy.entry("long", strategy.long, when = longCondition)
//strategy.close("long", when = o2>c2 , comment="ha_long")
strategy.entry("short", strategy.short , when =shortCondition )
//strategy.close("short", when = o2<=c2 , comment = "ha_short" )

//strategy.close("long",when=long_profit_level1 or long_stop_level  , comment="tp/sl")
//strategy.close("short",when=short_profit_level1 or short_stop_level , comment="tp/sl")

strategy.exit("x_long","long",profit = tp, loss = sl) //when = o2>c2)
strategy.exit("x_short","short",profit = tp, loss = sl) //when = o2<c2)



もっと