Combining WaveTrend & Squeeze

Ramos

New member
Hello all fellow traders, so I have these 2 indicators id like to combine except when I do I get an error on "Input-Price" all the way at the bottom and I've tried to work things around and still can't get it to work. bellow are the 2 codes separated and need help combining them. can someone point me in the right direction please. Thank you for your time.

1st lower indicator
Ruby:
input channel_length = 10; #10
input average_length = 21; #10
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 = yes;

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);
plot zero = 0;

zero.SetDefaultColor(Color.GRAY);

plot obLevel1 = over_bought_1;
obLevel1.SetDefaultColor(Color.DOWNTICK);
obLevel1.SetStyle(Curve.SHORT_DASH);
plot obLevel2 = over_bought_2;
obLevel2.SetDefaultColor(Color.DOWNTICK);
obLevel2.SetStyle(Curve.SHORT_DASH);
plot osLevel1 = over_sold_1;
osLevel1.SetDefaultColor(Color.LIGHT_GREEN);
osLevel1.SetStyle(Curve.SHORT_DASH);
plot osLevel2 = over_sold_2;
osLevel2.SetDefaultColor(Color.LIGHT_GREEN);
osLevel2.SetStyle(Curve.SHORT_DASH);
plot wt1_1 = wt1;
wt1_1.SetDefaultColor(Color.CYAN);
plot wt2_1 = wt2;
wt2_1.SetDefaultColor(Color.MAGENTA);

def signal1 = wt1 crosses above wt2 and wt1 < over_sold_2;
plot Signal = if signal1 then (signal1 * over_sold_2) else Double.NaN;

Signal.SetDefaultColor(Color.GREEN);
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_2) else Double.NaN;

Signal2_.SetDefaultColor(Color.RED);
Signal2_.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
Signal2_.SetLineWeight(2);
Signal2_.HideTitle();

input price = CLOSE;
input length = 20;
input nK = 1.5;
input nBB = 2.0;
input alertLine = 1.0;
plot Histogram = Double.NaN;
plot VolComp = Double.NaN;
plot SqueezeAlert = Double.NaN;


2nd Lower indicator
Ruby:
declare lower;

input Slength = 20; #hint Slength: Length for Squeeze
input Klength = 20; #hint Klength: Length for Oscillator
input price = close;
input SDmult = 2.0;
input ATRmult = 1.5;

def K = (Highest(high, Klength) + Lowest(low, Klength)) /
2 + ExpAverage(close, Klength);
plot Momo = Inertia(price - K / 2, Klength);
Momo.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Momo.SetLineWeight(3);
Momo.assignValueColor(if Momo > Momo[1] and Momo > 0
then Color.Cyan
else if Momo > 0 and Momo < Momo[1]
then Color.Blue
else if Momo < 0 and Momo < Momo[1]
then Color.Red
else Color.Yellow);
def SD = StDev(close, Slength);
def Avg = Average(close, Slength);
def ATR = Average(TrueRange(high, close, low), Slength);
def SDup = Avg + (SDmult * SD);
def ATRup = Avg + (ATRmult * ATR);
plot Squeeze = if SDup < ATRup
then 0
else Double.NaN;
Squeeze.SetPaintingStrategy(PaintingStrategy.POINTS);
Squeeze.SetLineWeight(3);
Squeeze.SetDefaultColor(Color.RED);
plot zero = if IsNaN(close) or !IsNaN(Squeeze) then Double.NaN else 0;
zero.SetPaintingStrategy(PaintingStrategy.POINTS);
zero.SetLineWeight(3);
zero.SetDefaultColor(Color.GREEN);
AddLabel(!IsNaN(Squeeze), "Squeeze", if IsAscending(Momo)
then Color.GREEN
else Color.RED);
# End Code - Momentum Squeeze

AddVerticalLine(!IsNaN(squeeze[1]) and IsNaN(squeeze), "Fired", Color.RED, Curve.FIRM);


#ADDED Volume###################################################################
#Colored Volume By Ethans080901
#Mod TroyX-8-17-18
#If today's closing price and volume is greater than 'n' days ago, color green
#If today's closing price is greater than 'n' days ago but volume is not, color blue
#If today's closing price is less than 'n' days ago, color orange
#If today's closing price is less than 'n' days ago but volume is not, color red

input n = 10;

def CN = Average(close, n);
def VN = Average(volume, n);
def G = close > CN and volume > VN ;
def B = close > CN and volume == VN;
def O = close < CN and volume == VN;
def R = close < CN and volume >= VN;

#Added volume Label
AddLabel( G, "Bullish Volume" , Color.CYAN); #Strong Bull
AddLabel( B, "Bullish Volume" , Color.BLUE); #Weak Bull
AddLabel( O, "Bearish Volume" , Color.YELLOW); #Weak Bear
AddLabel( R, "Bearish Volume" , Color.ORANGE); #Strong Bear

#How to use:
#Buy on Green or Blue
#Sell on Yellow or Orange

#End
 
Last edited by a moderator:
Solution
oh i see. this works .. I removed the 2nd price and changed the 2nd zero plot to zero2

Code:
declare Lower;

input channel_length = 10; #10
input average_length = 21; #10
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 = yes;

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);
plot zero = 0;

zero.SetDefaultColor(Color.GRAY);

plot obLevel1 = over_bought_1;
obLevel1.SetDefaultColor(Color.DOWNTICK)...
Why combine them into one study? they look fine when overlapped into one Lower. simply drag one on the other in your lower studies.

Hey thanks for the response and taking the time to check it out, we’ll that’s what I’ve been doing but was looking into merging them together so that when and only in travel it would come cleaner on the ipad so it wouldn’t chunch the chart as much as supposed to having the 2 lower studies separately.
 
oh i see. this works .. I removed the 2nd price and changed the 2nd zero plot to zero2

Code:
declare Lower;

input channel_length = 10; #10
input average_length = 21; #10
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 = yes;

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);
plot zero = 0;

zero.SetDefaultColor(Color.GRAY);

plot obLevel1 = over_bought_1;
obLevel1.SetDefaultColor(Color.DOWNTICK);
obLevel1.SetStyle(Curve.SHORT_DASH);
plot obLevel2 = over_bought_2;
obLevel2.SetDefaultColor(Color.DOWNTICK);
obLevel2.SetStyle(Curve.SHORT_DASH);
plot osLevel1 = over_sold_1;
osLevel1.SetDefaultColor(Color.LIGHT_GREEN);
osLevel1.SetStyle(Curve.SHORT_DASH);
plot osLevel2 = over_sold_2;
osLevel2.SetDefaultColor(Color.LIGHT_GREEN);
osLevel2.SetStyle(Curve.SHORT_DASH);
plot wt1_1 = wt1;
wt1_1.SetDefaultColor(Color.CYAN);
plot wt2_1 = wt2;
wt2_1.SetDefaultColor(Color.MAGENTA);

def signal1 = wt1 crosses above wt2 and wt1 < over_sold_2;
plot Signal = if signal1 then (signal1 * over_sold_2) else Double.NaN;

Signal.SetDefaultColor(Color.GREEN);
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_2) else Double.NaN;

Signal2_.SetDefaultColor(Color.RED);
Signal2_.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
Signal2_.SetLineWeight(2);
Signal2_.HideTitle();

input price = CLOSE;
input length = 20;
input nK = 1.5;
input nBB = 2.0;
input alertLine = 1.0;
plot Histogram = Double.NaN;
plot VolComp = Double.NaN;
plot SqueezeAlert = Double.NaN;






input Slength = 20; #hint Slength: Length for Squeeze
input Klength = 20; #hint Klength: Length for Oscillator
input SDmult = 2.0;
input ATRmult = 1.5;

def K = (Highest(high, Klength) + Lowest(low, Klength)) /
2 + ExpAverage(close, Klength);
plot Momo = Inertia(price - K / 2, Klength);
Momo.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Momo.SetLineWeight(3);
Momo.assignValueColor(if Momo > Momo[1] and Momo > 0
then Color.Cyan
else if Momo > 0 and Momo < Momo[1]
then Color.Blue
else if Momo < 0 and Momo < Momo[1]
then Color.Red
else Color.Yellow);
def SD = StDev(close, Slength);
def Avg = Average(close, Slength);
def ATR = Average(TrueRange(high, close, low), Slength);
def SDup = Avg + (SDmult * SD);
def ATRup = Avg + (ATRmult * ATR);
plot Squeeze = if SDup < ATRup
then 0
else Double.NaN;
Squeeze.SetPaintingStrategy(PaintingStrategy.POINTS);
Squeeze.SetLineWeight(3);
Squeeze.SetDefaultColor(Color.RED);
plot zero2 = if IsNaN(close) or !IsNaN(Squeeze) then Double.NaN else 0;
zero2.SetPaintingStrategy(PaintingStrategy.POINTS);
zero2.SetLineWeight(3);
zero2.SetDefaultColor(Color.GREEN);
AddLabel(!IsNaN(Squeeze), "Squeeze", if IsAscending(Momo)
then Color.GREEN
else Color.RED);
# End Code - Momentum Squeeze

AddVerticalLine(!IsNaN(squeeze[1]) and IsNaN(squeeze), "Fired", Color.RED, Curve.FIRM);


#ADDED Volume###################################################################
#Colored Volume By Ethans080901
#Mod TroyX-8-17-18
#If today's closing price and volume is greater than 'n' days ago, color green
#If today's closing price is greater than 'n' days ago but volume is not, color blue
#If today's closing price is less than 'n' days ago, color orange
#If today's closing price is less than 'n' days ago but volume is not, color red

input n = 10;

def CN = Average(close, n);
def VN = Average(volume, n);
def G = close > CN and volume > VN ;
def B = close > CN and volume == VN;
def O = close < CN and volume == VN;
def R = close < CN and volume >= VN;

#Added volume Label
AddLabel( G, "Bullish Volume" , Color.CYAN); #Strong Bull
AddLabel( B, "Bullish Volume" , Color.BLUE); #Weak Bull
AddLabel( O, "Bearish Volume" , Color.YELLOW); #Weak Bear
AddLabel( R, "Bearish Volume" , Color.ORANGE); #Strong Bear

#How to use:
#Buy on Green or Blue
#Sell on Yellow or Orange

#End
 
Solution

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
171 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