ストックRSI トレーディング戦略

作者: リン・ハーンチャオチャン,日付: 2024-02-23 15:06:59
タグ:

img

概要

MoonFlag MACDモメンタムストックRSI取引戦略は,判断のためにMACD,モメンタムおよびストックRSI指標を使用する定量的な取引戦略である.それは主にビットコインとイーサリアムの日常取引に適している.

戦略の論理

戦略は,以下の重要な指標を用いて判断する.

  1. MACD インディケーター:高速SMA期間が50で,スローSMA期間が200で,市場で一般的に使用される50日線と200日線を表しています.このインディケーターは市場の長期トレンド方向を判断します.

  2. カスタム・モメント・インディケーター: ストック・インディケーターと本質的に類似し,市場の短期モメント方向を判断するために使用されます.

  3. ストックRSI インディケーター: 市場の強みや過買い/過売水準を判断する.

ロングに入るために,MACD>0 (中長期上昇傾向を表す) の3つの条件,カスタムモメントインジケーター>0 (短期上昇勢力を表す) と前回の閉店値 (現在の上昇傾向を表す) の3つの条件を同時に満たす必要があります.

ロングシグナルを閉じるのは少し複雑で,MACD<0,カスタムモメントインジケーター <0,前回の閉じるよりも低い閉じる価格とStockRSI>20の4つの条件を同時に満たす必要があります.

戦略は中長期の傾向,短期の勢い,現在の傾向を包括的に評価し,比較的堅牢なブレークアウトシステムです.

戦略 の 利点

  1. 複数の指標を総合的に判断することで 誤った信号を生むことは避けられます

  2. MACD パラメータの選択は,市場における重要な50日線と200日線を考慮します.

  3. 各指標のパラメータの変動をテストした後,戦略の業績はわずかに変化し,過剰な適応リスクが回避されました.

  4. 十分なデータと高い信頼性でバックテスト

戦略 の リスク

  1. ブレイクアウトシステムは,取引数とスライプコストを増加させる可能性のある仲介傾向があります.

  2. 総合的な多指標判断と高い複雑性,パラメータ調整と最適化における困難

  3. 日中の短期取引リスクが高い

オプティマイゼーションの方向性

  1. 取引量などのより多くの指標の分析を組み込む

  2. ダイナミックパラメータ最適化のための機械学習アルゴリズムを増やす

  3. 取引頻度が低く,判断の頻度が高くなります.

概要

MoonFlag MACD モメントストックRSI トレーディング戦略は,複数の指標で市場動向と強みを包括的に判断し,バックテスト結果が良好で信頼性が高く,経験豊富な定量トレーダーが品質の暗号通貨に適用し最適化するのに適しています.


/*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")



もっと