二重移動平均とMACDを組み合わせた短期戦略


作成日: 2023-10-09 16:47:42 最終変更日: 2023-10-09 16:47:42
コピー: 0 クリック数: 749
1
フォロー
1617
フォロワー

概要

この戦略は,二重平均線,ランダム指数およびMACD指数を総合的に使用して,ショートライン取引の機会を識別し,より古典的なショートライン取引戦略に属します.

原則

この戦略は以下の原則に基づいています.

  1. 50周期と100周期のEMA平均線を用いて,トレンドの方向を判断する。EMA平均線は周期が短いため,価格の変化に素早く反応する。50周期線上を100周期線に突破することは入場を多めに表示する。50周期線下を100周期線に突破することは入場を空っぽに表示する。

  2. MACD指標の差離値を用いて売買のタイミングを判断する.差離が上から0穿戴すると多頭力が増し,多頭をする.差離が下から0穿戴すると空頭力が増し,空頭をする.

  3. ストキャスティックRSI指標と組み合わせて,超買い超売りかどうかを判断する. この指標は,KDJ指標とRSI指標の優位性を組み合わせて,市場の超買い超売り状況を表示することができます.指標が20を下回ると超売り,他の指標と組み合わせて多売り;指標が80を超えると超買い,他の指標と組み合わせて空売りである.

  4. ポジション開設の方向を決定した後,最近5つのK線が4つの閉盘価格が平均線に触れた場合,平均線の近くでサポートまたはプレッシャーがあることを示し,ポジションを開くことができます.

  5. ストップ・ストップ・ポイントのリスク管理.

利点

この戦略の利点は以下の通りです.

  1. 複数の指標の組み合わせ,平均線の総合的な使用,超買超売指標とエネルギー指標,取引勝利率の向上.

  2. 平均線周期が短く,トレンドを素早く把握し,逆転する.MACDパラメータの最適化,買い売りのタイミングを正確に識別する.

  3. ストキャスティックRSI指標のパラメータが最適化され,超買い超売り現象をよく識別できる.

  4. 平均線近くの支柱圧力を利用してペース制御を行い,無効突破で捕まるのを避ける.

  5. 合理的なストップ・ローズ,単一取引のリスクを効果的にコントロールする.

リスク

この戦略にはいくつかのリスクがあります.

  1. 破口の被害を完全に回避することは不可能である.

  2. 複数の指標の組み合わせが偏移し,取引信号が不一致する可能性があります.

  3. 固定ストップ・ストップ・ポイントは,市場の変化に適応できないかもしれない.

  4. コード実装は複雑で,パラメータが多く,最適化が難しい.

リスクに対応する解決策は以下の通りです.

  1. パラメータを最適化し,信号の質を高め,偽突破の確率を低減する.

  2. 標識の優先順位を設定し,信号の衝突を避ける.

  3. ストップ・ストップ・損失の動態を追跡し,ATRなどの指標に基づいてストップ・ストップ・損失の範囲を設定する.

  4. コードロジックを簡素化し,テストと最適化のためにコアパラメータを抽出します.

最適化の方向

この戦略は以下の方向から最適化できます.

  1. 平均線周期とMACDパラメータをテストし,最適なパラメータの組み合わせを見つける.

  2. ストキャスティックRSIの代替として,異なる超買い超売り指標をテストする.

  3. 動的ストップ・ストップ・ストップ,移動ストップ・ストップなどの方法を試し,損失管理をより賢くする.

  4. 取引量増加などのフィルタリング条件を追加し,信号の質を向上させます.

  5. ポジション開設の論理を最適化し,無効突破を防止する.より多くの指標判断トレンドを導入することができる.

  6. 口座の資金規模,日当たりの取引回数などのストップ・ロスの制限を設定し,全体的なリスクを制御する.

要約する

この戦略は,複数の指標の優位性を統合し,ショートライン取引において強力な実用性を持っています.パラメータを継続的に最適化し,厳格なポジション開設ロジック,損益管理戦略を改良することにより,戦略の安定性と収益性をさらに向上させることができます.この戦略は,一定の基礎を持つショートライントレーダーに適しています.しかし,大きな損失を避けるためにリスク管理に注意する必要があります.

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

//@version=4

strategy(title="Forex scalper 2xEMA + SRSI + MACD", shorttitle="Forex scalper 5-15min", overlay=true)
src = input(title="Source", type=input.source, defval=close)

src_0 = src[0]
src_1 = src[1]
src_2 = src[2]
src_3 = src[3]
src_4 = src[4]

len50 = input(50, minval=1, title="Length")
src50 = input(close, title="Source")
out50 = ema(src50, len50)
len100 = input(100)
src100 = input(close, title="Source")
out100 = ema(src100, len100)

len1 = input(1, minval=1, title="Length")
src1 = input(close, title="Source")
out1 = sma(src1, len1)

length = input(4, minval=1)
OverBought = input(80)
OverSold = input(20)
smoothK = 3
smoothD = 3

k = sma(stoch(close, high, low, length), smoothK)
d = sma(k, smoothD)
cu = crossover(k,OverSold)
co = crossunder(k,OverBought)

sma_down = crossunder(out1, out50)
sma_up = crossover(out1,out50)

//if (not na(k) and not na(d))
  //  if (co and k < OverSold)
    //    strategy.entry("StochLE", strategy.long, comment="StochLE")
    //if (cu and k > OverBought)
     //   strategy.entry("StochSE", strategy.short, comment="StochSE")

crossCandle_4 = crossover(src[4],out50)
crossCandleUnder_4= cross(src[4],out50)
crossCandle_3 = crossover(src[3],out50)
crossCandleUnder_3= crossunder(src[3],out50)
crossCandle_2 = crossover(src[2],out50)
crossCandleUnder_2= crossunder(src[2],out50)
crossCandle_1 = crossover(src[1],out50)
crossCandleUnder_1= crossunder(src[1],out50)
crossCandle_0 = crossover(src[0],out50)
crossCandleUnder_0= crossunder(src[0],out50)

conditionOver = (crossCandle_4 or crossCandle_3 or crossCandle_2 or crossCandle_1 or crossCandle_0)
conditionUnder =(crossCandleUnder_4 or crossCandleUnder_3 or crossCandleUnder_2 or crossCandleUnder_1 or crossCandleUnder_0)

touch4 = (cross(low[4],out50) or cross(high[4],out50))
touch3 = (cross(low[3],out50) or cross(high[3],out50))
touch2 = (cross(low[2],out50) or cross(high[2],out50))
touch1 = (cross(low[1],out50) or cross(high[1],out50))

touch = touch1 or touch2 or touch3 or touch4

//and sma_up
//and sma_down

// Getting inputs
fast_length = input(title="Fast Length", type=input.integer, defval=12)
slow_length = input(title="Slow Length", type=input.integer, defval=26)
src_macd = input(title="Source", type=input.source, defval=close)
signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 10)
sma_source = input(title="Simple MA(Oscillator)", type=input.bool, defval=false)
sma_signal = input(title="Simple MA(Signal Line)", type=input.bool, defval=false)

// Plot colors
col_grow_above = #26A69A
col_grow_below = #FFCDD2
col_fall_above = #B2DFDB
col_fall_below = #EF5350
col_macd = #0094ff
col_signal = #ff6a00

// Calculating
fast_ma = sma_source ? sma(src_macd, fast_length) : ema(src_macd, fast_length)
slow_ma = sma_source ? sma(src_macd, slow_length) : ema(src_macd, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal ? sma(macd, signal_length) : ema(macd, signal_length)
hist = macd - signal

//plot(hist, title="Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? col_grow_above : col_fall_above) : (hist[1] < hist ? col_grow_below : col_fall_below) ), transp=0 )
//plot(macd, title="MACD", color=col_macd, transp=0)
//plot(signal, title="Signal", color=col_signal, transp=0)


// plot((conditionOver or conditionUnder or touch)  and src[0] >= out50 and close >= out50 and  (cu) and out50 > out100 and hist>=0 , title="Buy", style=columns, color=lime)
// plot((conditionOver or conditionUnder or touch)  and src[0] <= out50 and close <= out50 and  (co) and out50< out100 and hist<=0 , title="sell", style=columns, color=red)


long_cond = ((conditionOver or conditionUnder or touch)  and src[0] >= out50 and close > out50 and  (cu) and out50 > out100 and hist>=0)
short_cond = ((conditionOver or conditionUnder or touch)  and src[0] <= out50 and close < out50 and  (co) and out50< out100 and hist<=0)

tp=input(200)
sl=input(200)

strategy.entry("long",strategy.long, when=long_cond)
strategy.entry("short",strategy.short, when=short_cond)

strategy.exit("X_long", "long", profit=tp,  loss=sl, when=touch  )
strategy.exit("x_short", "short",profit=tp, loss=sl,when = touch )