Display values of last 3 peaks of Weis Wave

SimpleStock

New member
Would it be possible to display values of last 3 peaks/valleys of price and volume with Addlabel or any other methods in the Weis Wave Zig Zag with Volume indicator ?
https://usethinkscript.com/threads/weis-wave-volume-indicator-for-thinkorswim.72/#post-308

BTW it will help us with identifying divergences easily. Three higher peaks with lower volumes and lower valleys with lower volume.
Attached is ES from 2/13/23

IrYeGh3.png
 
Last edited:
Solution
Would it be possible to display values of last 3 peaks/valleys of price and volume with Addlabel or any other methods in the Weis Wave Zig Zag with Volume indicator ?
https://usethinkscript.com/threads/weis-wave-volume-indicator-for-thinkorswim.72/#post-308

BTW it will help us with identifying divergences easily. Three higher peaks with lower volumes and lower valleys with lower volume.
Attached is ES from 2/13/23


can pick 1 to 4, for quantity of recent peak and valley data, to show in bubbles,
. close price
. volume

1 is most recent
2 is before #1
...

the last bar is ignored


Code:
# weis_wave_3peaks_00d

#https://usethinkscript.com/threads/display-values-of-last-3-peaks-of-weis-wave.14482/
#Questions UnAnswered...
Would it be possible to display values of last 3 peaks/valleys of price and volume with Addlabel or any other methods in the Weis Wave Zig Zag with Volume indicator ?
https://usethinkscript.com/threads/weis-wave-volume-indicator-for-thinkorswim.72/#post-308

BTW it will help us with identifying divergences easily. Three higher peaks with lower volumes and lower valleys with lower volume.
Attached is ES from 2/13/23


can pick 1 to 4, for quantity of recent peak and valley data, to show in bubbles,
. close price
. volume

1 is most recent
2 is before #1
...

the last bar is ignored


Code:
# weis_wave_3peaks_00d

#https://usethinkscript.com/threads/display-values-of-last-3-peaks-of-weis-wave.14482/
#Questions UnAnswered Graveyard
#UnAnswered Display values of last 3 peaks of Weis Wave
#SimpleStock  Feb 14, 2023

#Would it be possible to display values of last 3 peaks/valleys of price and volume with Addlabel or any other methods in the Weis Wave Zig Zag with Volume indicator ?
#https://usethinkscript.com/threads/weis-wave-volume-indicator-for-thinkorswim.72/#post-308

#BTW it will help us with identifying divergences easily. Three higher peaks with lower volumes and lower valleys with lower volume.
#Attached is ES from 2/13/23

#-------------------------------

#https://usethinkscript.com/threads/weis-wave-volume-indicator-for-thinkorswim.72/#post-308
#Weis Wave Volume Indicator for ThinkorSwim
#BenTen  Feb 25, 2019
#Here is the Weis Wave Volume indicator for ThinkorSwim converted from the Lazy Bear's version over at TradingView. In addition, I also found another indicator called Weis Wave Volume with ZigZag so I'll include that in this post as well.

#---------------------------------

# Weis Wave Zig Zag with Volume

#Note: The Weis Wave indicator shows price waves associated with the Weis Wave Volume lower indicator.
#Note: The reversalAmount: Indicate the minimum amount price must reverse before an inflection point can be formed. This value should be set the same on the lower Weis Wave Volume indicator.

declare upper;

input price = hlc3;
input reversalAmount = 1.0;
input reversalMode = {default price, percent};
input displayMode = {default volume, barNumber, barTotal, none};

def mode = if  reversalMode ==  reversalMode.price then ZigZagTrendSign(price = price, reversalAmount=reversalAmount) else ZigZagTrendPercent(price = price, reversalAmount=reversalAmount);
def inflection = if reversalMode == reversalMode.price then if !isNan(ZigZagSign(price = price, reversalAmount=reversalAmount)) then 1 else 0 else if !isNan(ZigZagPercent(price = price, reversalAmount=reversalAmount)) then 1 else 0;
rec trend = if inflection==1 and mode ==-1 then 1 else if inflection==1 and mode==1 then -1 else trend[1];

plot wave =  if  reversalMode ==  reversalMode.price then ZigZagSign(price = price, reversalAmount=reversalAmount) else ZigZagPercent(price = price, reversalAmount=reversalAmount);
wave.EnableApproximation();
wave.AssignValueColor(if trend[1] == 1 then color.green else color.red);
wave.SetLineWeight(3);

rec upWaveVolume = if inflection == 1 and trend == 1 and close > open then volume else if inflection == 1 and trend == 1 and close <= open then 0 else if trend == 1 or (inflection == 1 and trend == -1 and close >= open) then upWaveVolume[1] + volume else 0;
rec downWaveVolume = if inflection == 1 and trend == -1  and close < open then volume else if inflection == 1 and trend == -1 and close >= open then 0 else if trend == -1 or (inflection == 1 and trend == 1 and close <= open) then downWaveVolume[1] + volume else 0;

rec barsUp = if inflection == 1 and trend == 1  and close > open then 1 else if inflection == 1 and trend == 1 and close <= open then 0 else if trend == 1 or (inflection == 1 and trend == -1 and close >= open) then barsUp[1] + 1 else 0;
rec barsDown =  if inflection == 1 and trend == -1  and close < open then 1 else if inflection == 1 and trend == -1 and close >= open then 0 else if trend == -1 or (inflection == 1 and trend == 1 and close <= open) then barsDown[1] + 1 else 0;

plot uCount = if (displayMode == displayMode.barNumber and barsUp) then barsUp else double.nan;
uCount.SetPaintingStrategy(paintingStrategy.VALUES_BELOW);
uCount.SetDefaultColor(color.dark_green);

plot dCount = if (displayMode == displayMode.barNumber and barsDown) then barsDown else double.nan;
dCount.SetPaintingStrategy(paintingStrategy.VALUES_ABOVE);
dCount.SetDefaultColor(color.red);

plot uCountTot =  if (displayMode == displayMode.barTotal and barsDown == 1 and barsUp==0) then barsUp[1] else double.nan;
uCountTot.SetPaintingStrategy(paintingStrategy.VALUES_ABOVE);
uCountTot.SetDefaultColor(color.dark_green);

plot dCountTot = if (displayMode == displayMode.barTotal and barsDown==0 and barsUp==1) then barsDown[1] else double.nan;
dCountTot.SetPaintingStrategy(paintingStrategy.VALUES_BELOW);
dCountTot.SetDefaultColor(color.red);

plot uVol = if (displayMode == displayMode.volume and barsDown == 1 and barsUp==0) then upWaveVolume[1] else double.nan;
uVol.SetPaintingStrategy(paintingStrategy.VALUES_ABOVE);
uVol.SetDefaultColor(color.dark_green);

plot dVol = if (displayMode == displayMode.volume and barsUp == 1 and barsDown==0) then downWaveVolume[1] else double.nan;
dVol.SetPaintingStrategy(paintingStrategy.VALUES_BELOW);
dVol.SetDefaultColor(color.red);


#------------------------------------------

#  display values of last 3 peaks/valleys of price and volume

# trend:
#  peak = -1
#  valley = +1
#  on last bar = can be either +or-

def na = double.nan;
def bn = barnumber();

def lastbn = HighestAll(If(IsNaN(close), 0, bn));
def lastbar = if (bn == lastbn) then 1 else 0;
#def lastbar = !isnan(close[0]) and isnan(close[-1]);


def peakcnt = if bn == 1 then 0
 else if isnan(wave) or isnan(trend) then peakcnt[1]
 else if lastbar then peakcnt[1]
 else if !isnan(wave) and trend == -1 then peakcnt[1] + 1
 else peakcnt[1];

def valleycnt = if bn == 1 then 0
 else if isnan(wave) or isnan(trend) then valleycnt[1]
 else if lastbar then valleycnt[1]
 else if !isnan(wave) and trend == 1 then valleycnt[1] + 1
 else valleycnt[1];

def peakmax = highestall(peakcnt);
def valleymax = highestall(valleycnt);

def peakrevcnt = peakmax - peakcnt + 1;
def valleyrevcnt = valleymax - valleycnt + 1;


input qty_of_last_peaks_valleys = 2;
def q = qty_of_last_peaks_valleys;
# max of 4

def p1pr = if bn == 1 then 0 else if q >= 1 and peakrevcnt == 1 and peakrevcnt[1] != 1 then close else p1pr[1];
def p2pr = if bn == 1 then 0 else if q >= 2 and peakrevcnt == 2 and peakrevcnt[1] != 2 then close else p2pr[1];
def p3pr = if bn == 1 then 0 else if q >= 3 and peakrevcnt == 3 and peakrevcnt[1] != 3 then close else p3pr[1];
def p4pr = if bn == 1 then 0 else if q >= 4 and peakrevcnt == 4 and peakrevcnt[1] != 4 then close else p4pr[1];

def p1vol = if bn == 1 then 0 else if q >= 1 and peakrevcnt == 1 and peakrevcnt[1] != 1 then volume else p1vol[1];
def p2vol = if bn == 1 then 0 else if q >= 2 and peakrevcnt == 2 and peakrevcnt[1] != 2 then volume else p2vol[1];
def p3vol = if bn == 1 then 0 else if q >= 3 and peakrevcnt == 3 and peakrevcnt[1] != 3 then volume else p3vol[1];
def p4vol = if bn == 1 then 0 else if q >= 4 and peakrevcnt == 4 and peakrevcnt[1] != 4 then volume else p4vol[1];


def v1pr = if bn == 1 then 0 else if q >= 1 and valleyrevcnt == 1 and valleyrevcnt[1] != 1 then close else v1pr[1];
def v2pr = if bn == 1 then 0 else if q >= 2 and valleyrevcnt == 2 and valleyrevcnt[1] != 2 then close else v2pr[1];
def v3pr = if bn == 1 then 0 else if q >= 3 and valleyrevcnt == 3 and valleyrevcnt[1] != 3 then close else v3pr[1];
def v4pr = if bn == 1 then 0 else if q >= 4 and valleyrevcnt == 4 and valleyrevcnt[1] != 4 then close else v4pr[1];

def v1vol = if bn == 1 then 0 else if q >= 1 and valleyrevcnt == 1 and valleyrevcnt[1] != 1 then volume else v1vol[1];
def v2vol = if bn == 1 then 0 else if q >= 2 and valleyrevcnt == 2 and valleyrevcnt[1] != 2 then volume else v2vol[1];
def v3vol = if bn == 1 then 0 else if q >= 3 and valleyrevcnt == 3 and valleyrevcnt[1] != 3 then volume else v3vol[1];
def v4vol = if bn == 1 then 0 else if q >= 4 and valleyrevcnt == 4 and valleyrevcnt[1] != 4 then volume else v4vol[1];


def bubx = 2;
def bub = !isnan(close[bubx+1]) and isnan(close[bubx]);

addchartbubble(bub, close[bubx+1],
"Peaks\n" +
"1  " + round(p1pr, 2) + "  " + p1vol + "\n" +
"2  " + round(p2pr, 2) + "  " + p2vol + "\n" +
"3  " + round(p3pr, 2) + "  " + p3vol + "\n" +
"4  " + round(p4pr, 2) + "  " + p4vol + "\n"
, color.yellow, yes);

addchartbubble(bub, close[bubx+1],
"Valleys\n" +
"1  " + round(v1pr, 2) + "  " + v1vol + "\n" +
"2  " + round(v2pr, 2) + "  " + v2vol + "\n" +
"3  " + round(v3pr, 2) + "  " + v3vol + "\n" +
"4  " + round(v4pr, 2) + "  " + v4vol + "\n"
, color.yellow, no);


#------------------------------------


input test1 = no;
addchartbubble(test1, low*0.995,
wave + " w\n" +
trend + " t\n" +
peakmax + " pm\n" +
peakcnt + " pc\n" +
peakrevcnt + " pr\n" +
"----\n" +
valleymax + " vm\n" +
valleycnt + " v\n" +
valleyrevcnt + " vr"
, color.yellow, no);


input test2 = no;
addchartbubble(test2, low*0.995,
wave + " w\n" +
trend + " t\n" +

#peakmax + " pm\n" +
#peakcnt + " pc\n" +
peakrevcnt + " pr\n" +
#close + "\n" +

"----\n" +
#valleymax + " vm\n" +
#valleycnt + " v\n" +
valleyrevcnt + " vr"
, color.yellow, no);
#
#

NEE 5min
quantity of 2
WkNfjgV.jpg
 
Solution

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
273 Online
Create Post

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