Get alerted when 2 scripts align

Hi, I was wondering if there is a way to get an alert when two separate indicators align, say on the same bar? One indicator is an upper study and one is lower.

gO5Qpfp.png


The Criteria for an alert on SAME bar or within 1 bar ( see picture)

Up Alerts
WeakBBUp + Signal (wavetrend)
WeakRSIUp + Signal (wavetrend)

Down Alerts

WeakBBDown + Signal2_ (wavetrend)
WeakRSIDown + Signal2_ (wavetrend)

1st Script, WaveTrend

Code:
#Wave Trend Indicator
declare lower;
input Channel_Length = 10;
input Average_Length = 15;
input over_bought_1 = 60;
input over_bought_2 = 53;
input over_sold_1 = -60;
input over_sold_2 = -53;
input show_bubbles = yes;
input show_sec_bbls = no;
input show_alerts = no;
def ap = hlc3;
def esa = ExpAverage(ap, Channel_Length);
def d = ExpAverage(AbsValue(ap - esa), Channel_Length);
def ci = (ap - esa) / (0.015 * d);
def tci = ExpAverage(ci, Average_Length);
def wt1 = tci;
def wt2 = SimpleMovingAvg(wt1, 4);
#def zero = 0;


plot wt1_1 = wt1;
#wt1_1.SetDefaultColor(Color.WHITE);
plot wt2_1 = wt2;
#wt2_1.SetDefaultColor(Color.CYAN);
plot wt3 = (wt1 - wt2);
wt3.SetDefaultColor(Color.BLUE);

wt1_1.AssignValueColor(if wt1_1 > wt2_1
                           then Color.GREEN
                           else Color.RED);
wt2_1.AssignValueColor(if wt1_1 > wt2_1
                             then Color.GREEN
                             else Color.RED);

AddCloud(wt1_1, wt2_1, Color.GREEN, Color.RED);


wt3.SetDefaultColor(GetColor(5));
wt3.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
wt3.SetLineWeight(3);
wt3.DefineColor("Positive and Up", Color.GREEN);
wt3.DefineColor("Positive and Down", Color.DARK_GREEN);
wt3.DefineColor("Negative and Down", Color.RED);
wt3.DefineColor("Negative and Up", Color.DARK_RED);
wt3.AssignValueColor(if wt3 >= 0 then if wt3 > wt3[1] then wt3.Color("Positive and Up") else wt3.Color("Positive and Down") else if wt3 < wt3[1] then wt3.Color("Negative and Down") else wt3.Color("Negative and Up"));

def signal1 = wt1 crosses above wt2 and wt1 < over_sold_2;
plot Signal = if signal1  then (signal1 * over_sold_1) else Double.NaN;
Signal.SetDefaultColor(Color.WHITE);
Signal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
Signal.SetLineWeight(2);
Signal.HideTitle();
def signal2 = wt1 crosses below wt2 and wt1 > over_bought_2;
plot Signal2_ = if signal2  then (signal2 * over_bought_1) else Double.NaN;
Signal2_.SetDefaultColor(Color.WHITE);
Signal2_.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
Signal2_.SetLineWeight(2);
Signal2_.HideTitle();

plot zero = 0;
zero.SetDefaultColor( Color.YELLOW);
plot upmid = 30;
upmid.SetDefaultColor( Color.dark_ORANGE);
plot lowmid = -30;
lowmid.SetDefaultColor( Color.LIGHT_GREEN);
plot obLevel1 = over_bought_1;
obLevel1.SetDefaultColor(Color.RED);
plot osLevel1 = over_sold_1;
osLevel1.SetDefaultColor(Color.GREEN);
plot  obLevel2 = over_bought_2;
obLevel2.SetDefaultColor(Color.RED);
obLevel2.SetStyle(Curve.SHORT_DASH);
plot  osLevel2 = over_sold_2;
osLevel2.SetDefaultColor(Color.GREEN);
osLevel2.SetStyle(Curve.SHORT_DASH);

Second Script, Hot%

Code:
# Idea by Adeel & Boar
# Cleaned by Chewie

declare upper;
input length = 14;
input StrongSignal = yes;
input WeakSignal = yes;
input StrongSensitivity = 1; # lower number gets fewer results.
input WeakSensitivityBUY = -30; # closer to 0 gets more results.
input WeakSensitivitySELL = 30; # closer to 0 gets more results.

def price = close;
def averageType = AverageType.WILDERS;
def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = (50 * (ChgRatio + 1)) * -1;
def MiddleLine = 0;
def TakeProfit = 60;
def BUY = -60;
def vol = imp_volatility();
input TimePeriod = 252;
def data = if !IsNaN(vol) then vol else vol[-1];
def hi = Highest(data, TimePeriod);
def lo = Lowest(data, TimePeriod);
def Percentile = ((data - lo) / (hi - lo) * 100) * -1;
def lowend = Percentile < 25;
def highend = Percentile > 50;
def HotZone = Percentile - RSI;
def HotZoneHigh = Hotzone > WeakSensitivitySELL and Hotzone < 59;
def HotZoneLow = Hotzone < WeakSensitivityBUY and Hotzone > -59;

### Caution Relationship (RSI and IV) ###
def CAUTION = If(HotZone < -45 and HotZone > -60, 1, Double.NaN);
def CAUTION_S = If(HotZone > 45 and HotZone < 60, 1, Double.NaN);

### HOT Relationship (RSI and IV) ###
def RSIIV2 = if HotZone <= -60 then 1 else 0;
def HOT = if RSIIV2 then 0 else Double.NaN;
def RSIIV2_S = if HotZone >= 60 then 1 else 0;
def HOT_S = if RSIIV2_S then 0 else Double.NaN;

#Hot & Caution Labels
AddLabel(Hot, "HOT - POSSIBLE BUY", Color.GREEN);
AddLabel(Caution, "CAUTION - BUY INCOMING", Color.Yellow);
AddLabel(Hot_S, "HOT - POSSIBLE SELL", Color.RED);
AddLabel(Caution_S, "CAUTION - SELL INCOMING", Color.Yellow);

#HotZone Arrows
def UpSignal = HotZone crosses above BUY;
def DownSignal = HotZone crosses below TakeProfit;

#PERCENT BB
input averageType_BB = AverageType.Simple;
input length_BB = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;

def displace = 0;
def upperBand = BollingerBands(price, displace, length_BB, Num_Dev_Dn, Num_Dev_up, averageType_BB).UpperBand;
def lowerBand = BollingerBands(price, displace, length_BB, Num_Dev_Dn, Num_Dev_up, averageType_BB).LowerBand;
def PercentB = (price - lowerBand) / (upperBand - lowerBand) * 100;
def ZeroLine = 0.75;
def UnitLine = 99;
def UpSignal_BB = PercentB crosses above ZeroLine within Strongsensitivity bars;
def DownSignal_BB = PercentB crosses below UnitLine within Strongsensitivity bars;

#Signals
plot StrongUp = if StrongSignal and UpSignal and UpSignal_BB then 1 else Double.Nan;
plot StrongDn = if StrongSignal and DownSignal and DownSignal_BB then 1 else Double.Nan;
plot WeakBBUp =  if WeakSignal and PercentB crosses above ZeroLine and HotzoneLow then 1 else Double.Nan;
plot WeakBBDown = if WeakSignal and PercentB crosses below UnitLine and HotzoneHigh then 1 else Double.Nan;
plot WeakRSIUp = Upsignal;
plot WeakRSIDown = Downsignal;

WeakBBUp.SetDefaultColor(Color.light_green);
WeakBBUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
WeakBBUp.SetLineWeight(3);
WeakBBDown.SetDefaultColor(Color.magenta);
WeakBBDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
WeakBBDown.SetLineWeight(3);

WeakRSIUp.SetDefaultColor(Color.lime);
WeakRSIUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
WeakRSIUp.SetLineWeight(3);

WeakRSIDown.SetDefaultColor(Color.pink);
WeakRSIDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
WeakRSIDown.SetLineWeight(3);

StrongUp.SetDefaultColor(Color.light_gray);
StrongUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
StrongUp.SetLineWeight(4);
StrongDn.SetDefaultColor(Color.light_gray);
StrongDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
StrongDn.SetLineWeight(4);

# Alerts
Alert(Strongup, " ", Alert.Bar, Sound.Chimes);
Alert(Strongdn, " ", Alert.Bar, Sound.Bell);
 
Last edited:
I'm seeing multiple plots from each indicator. Could you be as specific as possible regarding which signal (from both indicators) needs to be aligned with each other?
 
Here you go, as requested:

Code:
#Wave Trend Indicator
input Channel_Length = 10;
input Average_Length = 15;
input over_bought_1 = 60;
input over_bought_2 = 53;
input over_sold_1 = -60;
input over_sold_2 = -53;
input show_bubbles = yes;
input show_sec_bbls = no;
input show_alerts = no;
def ap = hlc3;
def esa = ExpAverage(ap, Channel_Length);
def d = ExpAverage(AbsValue(ap - esa), Channel_Length);
def ci = (ap - esa) / (0.015 * d);
def tci = ExpAverage(ci, Average_Length);
def wt1 = tci;
def wt2 = SimpleMovingAvg(wt1, 4);
#def zero = 0;

def wt1_1 = wt1;
#wt1_1.SetDefaultColor(Color.WHITE);
def wt2_1 = wt2;
#wt2_1.SetDefaultColor(Color.CYAN);
def wt3 = (wt1 - wt2);


def signal1 = wt1 crosses above wt2 and wt1 < over_sold_2;
def Signal = if signal1  then (signal1 * over_sold_1) else Double.NaN;
def signal2 = wt1 crosses below wt2 and wt1 > over_bought_2;
def Signal2_ = if signal2  then (signal2 * over_bought_1) else Double.NaN;

def zero = 0;
def upmid = 30;
def lowmid = -30;
def obLevel1 = over_bought_1;

def osLevel1 = over_sold_1;
def  obLevel2 = over_bought_2;
def  osLevel2 = over_sold_2;


# Idea by Adeel & Boar
# Cleaned by Chewie

input length = 14;
input StrongSignal = yes;
input WeakSignal = yes;
input StrongSensitivity = 1; # lower number gets fewer results.
input WeakSensitivityBUY = -30; # closer to 0 gets more results.
input WeakSensitivitySELL = 30; # closer to 0 gets more results.

def price = close;
def averageType = AverageType.WILDERS;
def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = (50 * (ChgRatio + 1)) * -1;
def MiddleLine = 0;
def TakeProfit = 60;
def BUY = -60;
def vol = imp_volatility();
input TimePeriod = 252;
def data = if !IsNaN(vol) then vol else vol[-1];
def hi = Highest(data, TimePeriod);
def lo = Lowest(data, TimePeriod);
def Percentile = ((data - lo) / (hi - lo) * 100) * -1;
def lowend = Percentile < 25;
def highend = Percentile > 50;
def HotZone = Percentile - RSI;
def HotZoneHigh = Hotzone > WeakSensitivitySELL and Hotzone < 59;
def HotZoneLow = Hotzone < WeakSensitivityBUY and Hotzone > -59;

### Caution Relationship (RSI and IV) ###
def CAUTION = If(HotZone < -45 and HotZone > -60, 1, Double.NaN);
def CAUTION_S = If(HotZone > 45 and HotZone < 60, 1, Double.NaN);

### HOT Relationship (RSI and IV) ###
def RSIIV2 = if HotZone <= -60 then 1 else 0;
def HOT = if RSIIV2 then 0 else Double.NaN;
def RSIIV2_S = if HotZone >= 60 then 1 else 0;
def HOT_S = if RSIIV2_S then 0 else Double.NaN;

#Hot & Caution Labels
AddLabel(Hot, "HOT - POSSIBLE BUY", Color.GREEN);
AddLabel(Caution, "CAUTION - BUY INCOMING", Color.Yellow);
AddLabel(Hot_S, "HOT - POSSIBLE SELL", Color.RED);
AddLabel(Caution_S, "CAUTION - SELL INCOMING", Color.Yellow);

#HotZone Arrows
def UpSignal = HotZone crosses above BUY;
def DownSignal = HotZone crosses below TakeProfit;

#PERCENT BB
input averageType_BB = AverageType.Simple;
input length_BB = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;

def displace = 0;
def upperBand = BollingerBands(price, displace, length_BB, Num_Dev_Dn, Num_Dev_up, averageType_BB).UpperBand;
def lowerBand = BollingerBands(price, displace, length_BB, Num_Dev_Dn, Num_Dev_up, averageType_BB).LowerBand;
def PercentB = (price - lowerBand) / (upperBand - lowerBand) * 100;
def ZeroLine = 0.75;
def UnitLine = 99;
def UpSignal_BB = PercentB crosses above ZeroLine within Strongsensitivity bars;
def DownSignal_BB = PercentB crosses below UnitLine within Strongsensitivity bars;

#Signals
def StrongUp = if StrongSignal and UpSignal and UpSignal_BB then 1 else Double.Nan;
def StrongDn = if StrongSignal and DownSignal and DownSignal_BB then 1 else Double.Nan;
def WeakBBUp =  if WeakSignal and PercentB crosses above ZeroLine and HotzoneLow then 1 else Double.Nan;
def WeakBBDown = if WeakSignal and PercentB crosses below UnitLine and HotzoneHigh then 1 else Double.Nan;
def WeakRSIUp = Upsignal;
def WeakRSIDown = Downsignal;

# Modifications
plot up1 = WeakBBUp and Signal;
plot up2 = WeakRSIUp and Signal;
plot down1 = WeakBBDown and Signal2_;
plot down2 = WeakRSIDown and Signal2_;

up1.AssignValueColor(Color.CYAN);
up1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
up2.AssignValueColor(Color.CYAN);
up2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

down1.AssignValueColor(Color.MAGENTA);
down1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
down2.AssignValueColor(Color.MAGENTA);
down2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

# Alerts
Alert(up1, " ", Alert.Bar, Sound.Chimes);
Alert(down1, " ", Alert.Bar, Sound.Bell);
Alert(up1, " ", Alert.Bar, Sound.Chimes);
Alert(down2, " ", Alert.Bar, Sound.Bell);
 
Maybe this work work. Make sure to make the same adjustment for other conditions:

Code:
plot up1 = WeakBBUp within 5 bars and Signal within 5 bars;
 
Apologies for the newbie question - I was trying to scan for the StrongUp arrow but it didn't seem to result in anything (scanning for StrongUp is True?). If you could please help explain how to scan, I'd appreciate it - thanks very much
 
@asragov How did you set it up? This is how you should do it:

4m3sgcu.png


I didn't get any results either. If you look at your chart, you hardly see any up arrows. That could be the reason why. The signal is quite rare.
 
There are strong up arrows on the daily charts of most Dow 30 stocks around March, and on 30 minute charts, for example, recently, see Home Depot or Disney or Apple - just doesn't seem to find it in a scan ...
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
496 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top