
EMAとRSIの交差策は,指数移動平均 (((EMA) と相対的に強い指数 (((RSI) の2つの技術指標を組み合わせて,潜在的な買ったり売ったりするシグナルを識別する.EMAとRSIが交差したとき,市場の動きが変化する可能性を示します.例えば,短期のEMAがより長い周期のEMAを穿越し,RSIが特定の値下げを穿越すると,上昇傾向が起こりうることを示す,見張りの交差と呼ばれます.逆に,より短い周期のEMAがより長い周期を穿越し,RSIが特定の値下げを穿越すると,下降傾向が起こりうることを示す,見張りの交差と呼ばれます.
EMAとRSIの交差策は,トレンド追跡策として,トレンドと動力の2つの次元を組み合わせて,市場方向を比較的に全体的に判断することができる.同時に,この策は,信号品質とリスク管理能力を高めるために,いくつかのフィルタリング条件とダイナミックストップストップ方法を採用している.しかし,この策には,指標の遅れや頻繁な取引などのいくつかの制限がある.したがって,実際のアプリケーションでは,特定の市場特性と個人のリスク好みに応じて,戦略のさらなる最適化と改善が必要である.
/*backtest
start: 2023-05-28 00:00:00
end: 2024-06-02 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/
// © pritom980
//@version=5
strategy("EMA RSI Cross", overlay=true, margin_long=100, margin_short=100)
// add RSI
rsi_period = input.int(7,"RSI Period")
rsi_val = ta.rsi(close[1],rsi_period)
plot(rsi_val, color=color.blue, linewidth=2, title="RSI")
buyRsiFlag = rsi_val < 20
sellRsiFlag = rsi_val > 80
// add EMA
ema = ta.ema(close, 50)
plot(ema, color=color.red, linewidth=2, title="EMA")
// check buy
// buy when the price is below ema
buyFlag = ema > close ? true : false
// sell when the price is above ema
sellFlag = ema < close ? true : false
bgcolor(buyFlag and buyRsiFlag ? color.green : na )
bgcolor(sellFlag and sellRsiFlag ? color.red : na )
// Check if current candle's body is bigger than previous candle's body and of opposite color
is_body_bigger_long = math.abs(close - open) > math.abs(close[1] - open[1]) and close > open != close[1] > open[1]
greenCandle = close > close[1]
redCandle = close < close[1]
// Mark the candle
bgcolor(is_body_bigger_long and greenCandle and buyFlag ? color.blue : na, transp=70)
// ENTRY ---------------------
// Input for ATR period
atr_length = input(14, title="ATR Length")
// Calculate ATR
atr_value = ta.atr(atr_length)
// Calculate stop loss and take profit levels
candleBody = math.abs(close-open)
slDist = atr_value + candleBody
stop_loss_long = close - slDist
take_profit_long = close + (1.2 * slDist)
stop_loss_short = high + slDist
take_profit_short = high - (1.2 * slDist)
// Entry and exit conditions
if (buyFlag and buyRsiFlag and strategy.opentrades >= 0 and greenCandle)
strategy.entry("Long", strategy.long)
strategy.exit("Take Profit/Stop Loss", "Long", stop=stop_loss_long, limit=take_profit_long)
// Entry and exit conditions
if (sellFlag and sellRsiFlag and strategy.opentrades <= 0 and redCandle)
strategy.entry("Short", strategy.short)
strategy.exit("Take Profit/Stop Loss", "Short", stop=stop_loss_short, limit=take_profit_short)