ムーンフラッグ MACD モメンタム StochRSI 取引戦略


作成日: 2024-02-23 15:06:59 最終変更日: 2024-02-23 15:06:59
コピー: 0 クリック数: 584
1
フォロー
1617
フォロワー

ムーンフラッグ MACD モメンタム StochRSI 取引戦略

概要

月旗MACD動力StochRSI取引戦略は,MACD,動力およびStochRSIの3つの指標を使用して判断する量的な取引戦略である.この戦略は,主にビットコインとイーサリアムの日線取引に適用される.

戦略原則

この戦略は,以下の主要な指標を用いて判断します.

  1. MACD指数:急速SMA周期は50で,遅いSMA周期は200で,市場でよく使われる50日線と200日線を代表する.この指数は,市場の長期トレンド方向を判断する.

  2. 自作動量指標:本質的にストック指標に類似し,市場の短期的な動力の方向を判断するために使用される.

  3. ストックRSI指標:市場の強さと過剰買いと過剰売れを判断する

多頭に入るときは,同時にMACD>0 (中長期の上昇傾向を表す),自創動量指標>0 (短期の上昇傾向を表す) と,閉盤前日の値上げ (現在の上昇傾向を表す) の3つの条件を満たす必要があります.

平面多頭シグナルは,MACD<0,自創量指数<0,閉盘価格が前日より下落し,StochRSI>20の4つの条件を同時に満たす必要がある.

この戦略は,中長期の傾向,短期的な動向,そして現在の傾向を総合的に判断し,より堅牢な突破システムである.

戦略的優位性

  1. 複数の指標を統合して判断し,偽信号を避ける

  2. MACDパラメータは,市場にとって重要な50日線と200日線を考慮して選択された.

  3. 各指標のパラメータのテスト変更後,戦略効果はほとんど変化せず,過適合のリスクを回避

  4. 観測データは十分で信頼性が高い.

戦略リスク

  1. 破綻したシステムは利回りしやすいため,取引回数やスライドポイントのコストが増加する可能性があります.

  2. 総合的な多指標判断の複雑さ,パラメータの調整と最適化の難しさ

  3. 日中のショートラインの操作はリスクが高い.

戦略の最適化

  1. 取引量分析など,他の指標と組み合わせる

  2. 機械学習アルゴリズムを追加し,動態パラメータ最適化を実現する.

  3. 取引頻度を下げ,より高い周期に切り替える

要約する

月旗MACD動力StochRSI取引戦略は,市場の傾向と強さを判断する複数の指標を統合し,反測効果が良好で,信頼性が高く,経験豊富な量化トレーダーが高品質のデジタル通貨で適用および最適化するのに適しています.

ストラテジーソースコード
/*backtest
start: 2023-02-16 00:00:00
end: 2024-02-22 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/
// // © MoonFlag
//@version=5
strategy("MoonFlag 1D MACD Momentum StochRSI Strategy", max_bars_back=500, overlay=false, initial_capital=5000, default_qty_type=strategy.percent_of_equity, default_qty_value=80, pyramiding=0, calc_on_order_fills=true)


d(gaps_1, data)=>
    float out = 0.
    out :=(ta.wma(ta.wma(ta.wma(data,  math.round(((1 * gaps_1) - math.round((1 * gaps_1) / 3)) / 2)), math.round((1 * gaps_1) / 3)) , int(((1 * gaps_1) - math.round((1 * gaps_1) / 3)) / 2)))
    out
MoonFlagAverage(gaps_1,data)=>
    float out = 0.
    out:=d(gaps_1,d(gaps_1, d(gaps_1, data)))
    out

fastLength = input.int(50,  "MACD SMA Fast Length")
slowlength = input.int(200, "MACD SMA Slow Length")
MACDLength = 9//input.int(9,   "MACD Length")

MACD  = ta.ema(close, fastLength) - ta.ema(close, slowlength)
aMACD = ta.sma(MACD, MACDLength)
MACDdelta = MACD - aMACD

//plot (MACD, "MACD1", color.red)
//plot (aMACD, "aMACD1", color.green)
//plot (delta, "MACD delta", color.white)

fastLength2 = input.int(12, "MoonFlag Momentum Length")
slowlength2 = 2*fastLength2//input.int(50, "MoonFlag Momentum Slow Length")
MACDLength2 = 20//input.int(20, "Momentum Delta")

MoonFlag_MACD2 = MoonFlagAverage(fastLength2, close) - MoonFlagAverage(slowlength2,close)
MoonFlag_aMACD2 = MoonFlagAverage(MACDLength2, MoonFlag_MACD2)

MoonFlag_delta = MoonFlag_MACD2 - MoonFlag_aMACD2
MoonFlag_delta_line=0
if MoonFlag_delta < 0
    MoonFlag_delta_line:=-100
else
    MoonFlag_delta_line:=100
//plot (MoonFlag_MACD2, "MoonFlag Momentum Fast Length", color.red)
//plot (MoonFlag_aMACD2, "MoonFlag Momentum Slow Length", color.green)
//plot (MoonFlag_delta2, "MoonFlag Delta", color.white)

uptrend   = (close + high)/(close[1] + high[1])
downtrend =  (close + low)/(close[1] + low[1])

lineColor = color.green
if uptrend > 1
    lineColor := color.green
if downtrend < 1
    lineColor := color.red

smoothK     = 2//input.int(2, minval=1, title="K smoothing Stoch RSI")
smoothD     = 3//input.int(3, minval=1, title= "D smoothing for Stoch RSI")
lengthRSI   = 7//input.int(7, minval=1, title="RSI Length")
lengthStoch = 8//input.int(8, minval=1, title="Stochastic Length")
src = close//input(close, title="RSI Source")

rsi1 = ta.rsi(src, lengthRSI)
k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
StochRSI = ta.sma(k, smoothD)

MACDdirection_line = 0
MACDdirection_line := MACDdirection_line[1]
if (MACDdelta > 0) 
    MACDdirection_line := 50
if (MACDdelta < 0) 
    MACDdirection_line := -50

useStochRSI = input.bool(true,"Include Condition (StochRSI > 20) with Exit Long/Enter Short")
StochRSI_val = 20//input.int(20,"StochRSI greater than to exit short")
h1 = hline(StochRSI_val)

StochRSIGreaterThanSetValue = true
if useStochRSI
    if  (StochRSI > StochRSI_val)
        StochRSIGreaterThanSetValue := true
    else
        StochRSIGreaterThanSetValue := false

stoch20 = lineColor
if StochRSI < StochRSI_val
    stoch20 := color.white

yearin = input.int(2019, title="Start backtesting from year:")

includeShorts = false//input.bool(false, "Include Shorts")

plot(MoonFlag_delta_line,"MoonFlag Momentum Direction", color.white)
plot(MACDdirection_line,"MACD Direction", color = color.orange)
plot(StochRSI, "StochRSI", color=lineColor)

if  (year>=yearin)
    if (MACDdelta > 0) and (uptrend > 1)   and MoonFlag_delta_line > 0
        strategy.entry("buy2", strategy.long, comment="buy")
    if (MACDdelta < 0) and (downtrend < 1) and MoonFlag_delta_line < 0 and StochRSIGreaterThanSetValue
        if includeShorts    
            strategy.entry("sell", strategy.short, comment="sell")
        else
            strategy.close("buy2", comment = "sell")