strategy MACD and RSI alert

5534 6 612
This is a script I created by combining parts of other scripts I looked at. It uses RSI and MACD to give entrance signals for longs or shorts. When the color changes from red to green it signifies a buy, from green to red signifies a short.

The problem that I am having is that I cannot set up the alert script properly, Using the code :
alert1 = (xRSI > Overbought and signal < macd ) ? 1: 0

gives repeat signals every time the criteria reasserts itself, and I only want it to show an alert at the same time the bar color changes.
If I could get some advice on how to set up the alert so it only alerts me at the same time that the bars change color, it would be much appreciated.
Remove from Favorite Scripts Add to Favorite Scripts
study(title="Strategy MACD and RSI alert", shorttitle="Strategy MACD and RSI alert", overlay = false )
fastLength = input(8, minval=1)
slowLength = input(16,minval=1)
hline(0, color=purple, linestyle=dashed)
fastMA = ema(close, fastLength)
slowMA = ema(close, slowLength)
macd = fastMA - slowMA
signal = sma(macd, signalLength)

Length = input(10, minval=1)
Oversold = input(49, minval=1)
Overbought = input(51, minval=1)
xRSI = rsi(close, Length)

pos = iff(xRSI > Overbought and signal < macd, 1,
        iff(xRSI < Oversold and signal > macd, -1, nz(pos[1], 0))) 
barcolor(pos == -1 ? red: pos == 1 ? green : blue)

plot(pos, title="pos", style=line, linewidth=1, color=red )
Thanks Chris, this looks awesome
Here is the Video showing how to fix the Alerts so the Alerts ONLY Trigger when the Bars Change Colors.

Video Titled Creating Alerts - Specific Example By Request 1-05-2015 .... Currently Top Right Video on the page.
munsifk ChrisMoody
Thanks Chris, your help is really appreciated :)
no Problem.....You did the HARD Part.....
+3 Reply
thanks for this looks great will definitely use it:)!
munsifk jamestrade14
Thanks, it is really good but watch out for consolidations.
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing My Support Tickets Contact Support Ideas Published Followers Following Private Messages Chat Sign Out