Auto Buy Scalper 戦略でストカスティックRSI

作者: リン・ハーンチャオチャン, 日付: 2023-10-31 11:34:47
タグ:

img

概要

この戦略は,ストーカスティックRSIとEMA技術指標に基づく自動バイインとコインスケーパー取引戦略を実装することを目的としています.これはBTCに最適化された5分間のキャンドルスタイクのために設計されています.目標は横向または非重要なダウントレンド中にできるだけコインを保持することです.

戦略の論理

この戦略は,RSIインジケーターを使用して,過剰購入および過剰販売レベルを決定し,ストカスティックRSIのK値とD値の関係と組み合わせて,購入および販売信号を生成します.

ストキャスティックRSIK線が20を下回り,oversoldとみなされ,KがD以上になると購入信号を誘発します. その後,価格が1%以上上昇し,EMA逆転が続く3つの条件に基づいて売却するかどうかを決定します.

さらに,上昇傾向の後に短期EMAが下向きに回転すると,販売信号とみなされます.

利点

  • ストカスティックRSIを入力タイミングに使うのは より信頼性があり 誤ったブレイクを効果的にフィルタリングします
  • EMAを組み込むことで 傾向の変化のタイミングを より良く検出できます
  • ストップロスの適用は,損失を効果的に制御するのに役立ちます.
  • できるだけコインを保有することで 取引頻度と手数料を減らすことができます

リスク

  • RSIインジケーターからの潜在的な誤った信号です. RSIパラメータを細かく調整することで最適化できます.
  • ストップ・ロスの設定が狭すぎると 損失が増える可能性があります.ストップ・ロスの割合を適切に調整します.
  • EMA パラメータの設定が正しくない場合 トレンド変化のタイミングが間違える可能性があります

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

  • RSIとストカスティックRSIの異なる組み合わせをテストして最適設定をします.
  • 損失防止と引き下げをバランスするために 異なるストップ・ロスの割合を試してください
  • トレンドの変化を把握するための最適なパラメータを決定するために,長期と短期のEMAの組み合わせをテストする.
  • 入口と出口のタイミングの精度を高めるために他の指標を追加することを検討します.

概要

この戦略は,ストカスティックRSI,EMAおよび他の指標の強みを統合し,エントリーおよび出口タイミングを決定するために比較的堅牢な方法を使用している.パラメータ最適化およびリスク管理を通じて収益性と安定性のさらなる改善を達成することができる.全体的に,戦略論理は健全であり,ライブ取引で検証および最適化に値する.


/*backtest
start: 2023-09-30 00:00:00
end: 2023-10-30 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy(title="Stochastic RSI W Auto Buy Scalper Scirpt III ", shorttitle="Stoch RSI_III", format=format.price, precision=2)
smoothK = input.int(3, "K", minval=1)
smoothD = input.int(3, "D", minval=1)
lengthRSI = input.int(14, "RSI Length", minval=1)
lengthStoch = input.int(14, "Stochastic Length", minval=1)
src = input(close, title="RSI Source")
rsi1 = ta.rsi(src, lengthRSI)
k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = ta.sma(k, smoothD)
plot(k, "K", color=#2962FF)
plot(d, "D", color=#FF6D00)
h0 = hline(80, "Upper Band", color=#787B86)
hline(50, "Middle Band", color=color.new(#787B86, 50))
h1 = hline(20, "Lower Band", color=#787B86)

longStopLoss  = strategy.opentrades.entry_price(0)* (.985)

stochDropping = ta.falling(k,2)
shortSma = ta.sma(hlc3,12)
shorterSma = ta.sma(hlc3,3)
plot(shortSma[3])

shortSmaFlip = (ta.change(shortSma,3)>0) and ta.falling(hlc3,1)
shorterSmaFlip = (ta.change(shorterSma,2)>0) and ta.falling(hlc3,1)
messageSellText ='"type": "sell", "symbol": "BTCUSD", "marketPosition": "{{strategy.market_position}}"'

messageBuyText ='"type": "buy", "symbol": "BTCUSD", "marketPosition": {{strategy.market_position}}"'

fill(h0, h1, color=color.rgb(33, 150, 243, 90), title="Background")

strategy.entry("Tech", strategy.long, when=(strategy.position_size <= 0 and k<17 and k>d),alert_message=messageBuyText)
//original: strategy.close("TL", when=(strategy.position_size >= 0 and (k>90 and k<d)))

takeProfit = hlc3 > strategy.opentrades.entry_price(0)*1.01
//longStopLoss  = strategy.opentrades.entry_price(0)* (.995)

strategy.close("Tech", when=(strategy.position_size >= 0 and (k>90 and k<d and stochDropping)) or close<longStopLoss, comment="rsi or Stop sell",alert_message=messageSellText)
//strategy.close("Tech", when=(strategy.position_size >= 0 and close<longStopLoss), comment="stopLoss sell",alert_message=messageSellText)

strategy.close("Tech", when=(shortSmaFlip and k>20 and takeProfit),comment="Sma after profit",alert_message=messageSellText)



もっと