Weis Wave Volume Indicator for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
Warehouse
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.



thinkScript Code (Lazy Bear)

Rich (BB code):
#
# @author LazyBear
# List of all my indicators: https://www.tradingview.com/v/4IneGo8h/
#
# study(" [LazyBear]", shorttitle="WWV_LB")
declare lower;
declare zerobase;

# trendDetectionLength=input(2)
input trendDetectionLength = 3;

# mov = close>close[1] ? 1 : close<close[1] ? -1 : 0
def mov = If(close > close[1], 1, If(close < close[1], -1, 0));

# trend= (mov != 0) and (mov != mov[1]) ? mov : nz(trend[1])
# might cause problems not using the nan if statement...
def trend = If((mov != 0) and (mov != mov[1]), mov, (trend[1])) ;
# isTrending = rising(close, trendDetectionLength) or falling(close, trendDetectionLength) //abs(close-close[1]) >= dif
def isTrending = IsAscending(close, trendDetectionLength) or IsDescending(close, trendDetectionLength);

# wave=(trend != nz(wave[1])) and isTrending ? trend : nz(wave[1])
# might be a problem not using the nan function here
def wave = If((trend != (wave[1])) and isTrending, trend , (wave[1]) );

# vol=wave==wave[1] ? (nz(vol[1])+volume) : volume
# might be a problem not using the nan function here
def vol = If(wave == wave[1] , ((vol[1]) + volume) , volume ) ;

# up=wave == 1 ? vol : 0
plot up = If(wave == 1 , vol , 0 );

# dn=showDistributionBelowZero ? (wave == 1 ? 0 : wave == -1 ? -vol : vol) : (wave == 1 ? 0 : vol)
# plot dn = If(wave == 1, 0, If(wave == -1, -vol, vol));
plot dn = If(wave == 1, 0, If(wave == -1, vol, vol));

# plot(up, style=histogram, color=green, linewidth=3)

# plot(dn, style=histogram, color=red, linewidth=3)

dn.setDefaultColor(color.red);
up.setDefaultColor(color.green);
dn.SetLineWeight(3);
up.SetLineWeight(3);
up.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
dn.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

Weis Wave Zig Zag with Volume

Rich (BB code):
#
# Weis Wave
#

#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);
 
Last edited:
T

Topas

New member
It does not plot in, is idea why ? i tried couple of times ... can you post shareable link plz

 
Last edited:
T

Topas

New member
Well shareable link did not plot either ... There was no Error at all ... but it just did not plot ... but in studies it shows up as lower studies ... it just me or anyone else having the same issue ?

Thanks for the shareable link though....

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@Topas Both indicators doesn't plot?

 
Last edited:
T

Topas

New member
Yes Ben ... None of them plot ....

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@Topas I see what happen there. Go to Settings > Equities and make sure you enable "Show volume subgraph".



 
Last edited:
T

Topas

New member
It worked ... thank you. you know what i knew this option but did not realize this was the issue.

 
Last edited:
C

Chenthy73

New member
Thanks for sharing. One issue I found is that the 2nd one repaint historical bars (e.g., 5-6 bars which are already painted) from green to red or vice versa, which is a bad thing for after-fact editing. I fully understood the current bar in the making can change color, but not previous bars.

I need to see if the first one by Lazy Bear do the same.



 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@Chenthy73 I noticed that too thats why I stopped using it. Maybe it was converted thats why? I don't think the original indicator from TradingView will re-paint the bars altogether. Let me know if you find anything about the original indicator.

 
Last edited:
C

Chenthy73

New member
I don't think the two indicators you have listed in this post are the same.

I don't know the original Tradingview pine indicator for the 2nd one above which repaints in ToS. Will look into it a little bit more after work.

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@Chenthy73 I thought so too. Keep me posted pls

 
Last edited:
S

stocksniper

New member
Weis Wave Zig Zag with Volume - Can someone write a script to get sound alerts in the change of colors. Thanks
 
Last edited by a moderator:
S

stocksniper

New member
Can someone add "Sound Alert" to Weis Wave Zig Zag with Volume, when it changes colors. Thanks
 

Top