
この戦略は,ランダムな指数平移平均 ((RSI)) と指数移動平均 ((EMA)) の指標に基づく自主的なコインの購入と保有のスキャルパー取引戦略を実現することを目的としている.それは5分間のKラインに適用され,BTCに対して最適化されている.戦略の目的は横断または大幅な下落のないときにできるだけ多くのコインを保有することである.
この戦略は,RSI指標が超買超売領域にあるかどうかを判断するために使用され,ランダムなRSI指標のK値とD値の関係と組み合わせて,買入と売却のシグナルを発信する.
ランダムなRSIのK線が20を下回ると,超売りとみなされ,K線がD線より大きいときに買取シグナルが生じます.その後,3つの条件に基づいて,売却が判断されます: 1) 価格が1%以上上昇した後にEMAの反転が発生する; 2) ランダムなRSI指標のK線がD線を下回ると; 3) ストップ価格が入場価格の98.5%に達すると.
また,短期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)