
この戦略は,指数移動平均 ((EMA) と相対的に強い指数 ((RSI) による交差取引システムである.この戦略は,価格とEMAの交差,およびRSI指標の超買い超売りレベルによって,入場と出場のタイミングを決定する.システムは,完全な止損と利益の仕組みを設計し,リスクを効果的に制御することができる.
戦略は主に以下のコアロジックに基づいています.
この戦略は,EMAとRSIの2つのクラシックな技術指標を組み合わせて,トレンド追跡と反転の特徴を兼ね備えた取引システムを構築している. 完善したリスク管理機構と調整可能なパラメータ設計は,その実用性を良好にしている. しかし,戦略のパラメータ最適化と市場の適応性にはまだ改善の余地があり,トレーダーは,市場特性を組み合わせたターゲティング最適化を行うことを推奨している.
/*backtest
start: 2024-02-21 00:00:00
end: 2024-10-05 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=5
strategy("EMA & RSI Custom Strategy", overlay=true)
// Input Parameters
emaLength = input.int(68, title="EMA Length")
rsiLength = input.int(13, title="RSI Period")
buyOffset = input.float(2, title="Buy Offset (above EMA)")
sellOffset = input.float(2, title="Sell Offset (below EMA)")
stopLossPoints = input.float(20, title="Stop Loss (points)")
buyRSIProfitLevel = input.int(70, title="Buy RSI Profit Level")
sellRSIProfitLevel = input.int(28, title="Sell RSI Profit Level")
// EMA and RSI Calculations
ema = ta.ema(close, emaLength)
rsi = ta.rsi(close, rsiLength)
// Buy Condition
buyPrice = ema + buyOffset
buyCondition = ta.crossover(close, buyPrice)
if buyCondition
strategy.entry("Buy", strategy.long)
// Stop Loss and Profit for Buy
if strategy.position_size > 0
if close <= strategy.position_avg_price - stopLossPoints
strategy.close("Buy", comment="Stop Loss")
if rsi >= buyRSIProfitLevel
strategy.close("Buy", comment="Profit Target")
// Sell Condition
sellPrice = ema - sellOffset
sellCondition = ta.crossunder(close, sellPrice)
if sellCondition
strategy.entry("Sell", strategy.short)
// Stop Loss and Profit for Sell
if strategy.position_size < 0
if close >= strategy.position_avg_price + stopLossPoints
strategy.close("Sell", comment="Stop Loss")
if rsi <= sellRSIProfitLevel
strategy.close("Sell", comment="Profit Target")
// Plot EMA
plot(ema, color=color.blue, title="EMA 68")