VZO- Volume Zone Oscillator for ThinkorSwim (modified with alerts/color scheme)

chewie76

Active member
VIP
VIP Enthusiast
I added alerts for when VZO enters and exits the buy and sell zones. Also updated color scheme. No other changes to it.

KdKXz9E.png


Shareable link.
http://tos.mx/zCEpFos

Code:
# VZO
# Modified by Chewie
# Added alerts for entering and exiting the buy and sell zones
# and updated the color scheme 12/20/20
# TD Ameritrade IP Company, Inc. (c) 2011-2020
#
declare lower;

input length = 14;
input AlertsOn = yes;
def VP = ExpAverage(Sign(close - close[1]) * volume, length);
def TV = ExpAverage(volume, length);
plot VZO = 100 * VP / TV;
plot "+60" = 60;
plot "+40" = 40;
plot "-40" = -40;
plot "-60" = -60;
plot ZeroLine = 0;

VZO.DefineColor("Normal", color.white);
VZO.DefineColor("OverBought", color.red);
VZO.DefineColor("OverSold", color.green);
VZO.AssignValueColor(if VZO > "+60" then VZO.Color("OverBought") else if VZO < "-60" then VZO.Color("OverSold") else VZO.Color("Normal"));
"+60".SetDefaultColor(color.red);
"+40".SetDefaultColor(color.red);
"-40".SetDefaultColor(color.green);
"-60".SetDefaultColor(color.green);
ZeroLine.SetDefaultColor(color.yellow);

AddCloud("+60", "+40", Color.dark_RED, Color.CURRENT);
AddCloud("-40", "-60", Color.dark_GREEN, Color.CURRENT);

AddCloud(VZO, "+40", Color.RED, Color.CURRENT);
AddCloud("-40", VZO, Color.GREEN, Color.CURRENT);

def condition1 = VZO crosses above "+40";
def condition2 = VZO crosses below "+40";
def condition3 = VZO crosses below "-40";
def condition4 = VZO crosses above "-40";

# Alert
Alert(alertsOn and condition1, "Enter Sell Zone", Alert.BAR, Sound.RING);
Alert(alertsOn and condition2, "Exit Sell Zone", Alert.BAR, Sound.bell);
Alert(alertsOn and condition3, "Enter Buy Zone", Alert.BAR, Sound.RING);
Alert(alertsOn and condition4, "Exit Buy Zone", Alert.BAR, Sound.bell);
 

EarlyAMTrader

New member
OK so I made some modifications here (way above my level of coding... :) );
Code:
#VZO_Label

declare lower;

input length = 14;

def VP = ExpAverage(Sign(close - close[1]) * volume, length);
def TV = ExpAverage(volume, length);

def ADX = ADX (14);
def EMA60 = ExpAverage(close, 60);

plot VZO = 100 * VP / TV;
plot "+60" = 60;
plot "+40" = 40;
plot "+15" = 15;
plot "-5" = -5;
plot "-40" = -40;
plot "-60" = -60;
plot ZeroLine = 0;

VZO.SetDefaultColor(GetColor(1));
"+60".SetDefaultColor(GetColor(6));
"+40".SetDefaultColor(GetColor(6));
"+15".SetDefaultColor(GetColor(3));
"-5".SetDefaultColor(GetColor(3));
"-40".SetDefaultColor(GetColor(5));
"-60".SetDefaultColor(GetColor(5));
ZeroLine.SetDefaultColor(GetColor(4));

def trendExistence = ADX > 18;

# 1 = cross above, 2 = stays above, 3 = crosses below, 4 = stays below

def direction = if close > EMA60 and close[1] <= EMA60 then 1 else if close > EMA60 and close[1] >= EMA60 then 2 else if close < EMA60 and close[1] >= EMA60 then 3 else 4;

def bullishCrossover = if VZO >= +40 and VZO[1] < +40 then 1 else 0;
def bearishCrossover = if VZO <= -40 and VZO[1] > -40 then 1 else 0;

AddCloud(40, 60, color.light_red, color.light_red);
Addcloud (-40,-60, color.light_green, color.light_green);

def Above60 = VZO >= 60;
def Below60 = VZO < 60 and VZO >= 40;
def Above0 =  VZO > 0 and VZO < 40;
def Below0 = VZO < 0 and VZO > -40;
def BelowN40 = VZO <= -40 and VZO > -60;
def BelowN60= VZO <=-60;

AddLabel(Above60, “VZO > 60”, color.Dark_Green);
AddLabel(Below60, “VZO > 40”, color.Green);
AddLabel(Above0, “VZO > 0”, Color.CYAN);
AddLabel(Below0, “VZO < 0”, color.Orange);
AddLabel(BelowN40, “VZO < -40”, color.red);
AddLabel(BelowN60, “VZO < -60”, color.dark_Red);

I'm curious is someone can help modify the label even more and add an up and down label to each.

So for example I would like the below 60 and Above 40 to say "VZO > 40 Up" if direction moving (Uptrend) from 40 -> 60 and "VZO > 40 Down" if direction moving (downtrend) from 60 -> 40 direction.

Hope this makes sense.
 
Last edited:

Similar threads

Top