aaryamangumber400

EMA Crossover with RSI


ChatGPT
Certainly! Here's a TradingView Pine Script that combines EMA crossover with RSI to generate buy and sell signals. The script will give a buy signal when the 20 EMA crosses above the 50 EMA and the RSI is below a certain threshold (indicating it's not overbought). Similarly, it will give a sell signal when the 20 EMA crosses below the 50 EMA and the RSI is above a certain threshold (indicating it's not oversold).

pinescript
Copy code
//@version=5
indicator("EMA Crossover with RSI", overlay=true)

// Input for EMAs
ema20_length = input.int(20, title="20 EMA Length")
ema50_length = input.int(50, title="50 EMA Length")

// Input for RSI
rsi_length = input.int(14, title="RSI Length")
rsi_overbought = input.int(70, title="RSI Overbought Level")
rsi_oversold = input.int(30, title="RSI Oversold Level")

// Calculating EMAs
ema20 = ta.ema(close, ema20_length)
ema50 = ta.ema(close, ema50_length)

// Calculating RSI
rsi = ta.rsi(close, rsi_length)

// Plotting EMAs
plot(ema20, title="20 EMA", color=color.blue, linewidth=2)
plot(ema50, title="50 EMA", color=color.red, linewidth=2)

// Conditions for buy and sell signals
buy_condition = ta.crossover(ema20, ema50) and rsi < rsi_overbought
sell_condition = ta.crossunder(ema20, ema50) and rsi > rsi_oversold

// Plotting buy and sell signals on the chart
plotshape(series=buy_condition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sell_condition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

// Adding background color to highlight buy and sell zones
bgcolor(buy_condition ? color.new(color.green, 90) : na, title="Buy Background Highlight")
bgcolor(sell_condition ? color.new(color.red, 90) : na, title="Sell Background Highlight")
Explanation:
Input Parameters:

ema20_length and ema50_length to set the lengths for the EMAs.
rsi_length for the length of the RSI calculation.
rsi_overbought and rsi_oversold to set the levels for overbought and oversold conditions respectively.
Calculations:

ema20 and ema50 are calculated using ta.ema.
rsi is calculated using ta.rsi.
Conditions:

buy_condition checks for the crossover of ema20 above ema50 and that the RSI is below the overbought threshold.
sell_condition checks for the crossover of ema20 below ema50 and that the RSI is above the oversold threshold.
Plotting:

The EMAs are plotted on the chart.
Buy and sell signals are plotted using plotshape.
Background colors are added to highlight the buy and sell zones for better visual interpretation.
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?