TradingView

Code for the video “Creating Complex Сustom Alerts in TradingView”

Code for the video “Creating Complex Сustom Alerts in TradingView”

study(title="MA Cross Complex Alert", overlay=true)

// MAs
short = sma(close, 9)
long  = sma(close, 21)

// RSI
rsi_up   = rma( max(change(close), 0), 14)
rsi_down = rma(-min(change(close), 0), 14)
rsi = rsi_down == 0 ? 100 : rsi_up == 0 ? 0 : 100 - (100 / (1 + rsi_up / rsi_down))

// Williams %R
w_upper = highest(14)
w_lower = lowest(14)
w = 100 * (close - w_upper) / (w_upper - w_lower)

// Plot
plot(short, color = red)
plot(long,  color = green)
plot(cross(short, long) ? short : na, style = cross, linewidth = 4)

long_signal  = crossover( short, long) and rsi > 70  and w > -20
short_signal = crossunder( short, long) and rsi < 30 and w < -80

plotarrow(long_signal,   colorup = green)
plotarrow(-short_signal, colordown = red)

// alerts
alertcondition(long_signal,  title = "MA Complex long",   message = "MA long")
alertcondition(short_signal, title = "MA Complex short", message = "MA short")

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Pine Script Programming Courses
Pine Script Programming Courses
Learn to build your own TradingView Indicators and Strategies
Sidebar Signup Form
If you want to be the first in this business, subscribe to the latest news