Modify VZO indicator to display arrows on upper chart

juan david

New member
VIP
so found this script on another site i have adjusted it for daytrading scalping and would like to know if I could get some help adding a way to signal on the top chart (when the tzo touches or crosses the levels of 75 and -75 and 100 and -100). any help much appreciated. The main purpose is to serve as a confirmation signal for a trade... for instance if tzo is below -75 or at -100 you can look to go long paired with another level or the opposite if it is above at 75 or 100 look to sell or go short!!

CIBAn6S.png


Code:
declare lower;
input length = 14;

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

plot VZO = 100 * VP / TV;
plot "+100" = 100;
plot "+75" = 75;
plot "+28" = 28;
plot "+90" = 90;
plot "-28" = -28;
plot "-75" = -75;
plot "-90" = -90;
plot "-100" = -100;
plot ZeroLine = 0;

VZO.SetDefaultColor(GetColor(1));
"+100".SetDefaultColor(GetColor(6));
"+90".SetDefaultColor(GetColor(5));
"+75".SetDefaultColor(GetColor(6));
"-90".SetDefaultColor(GetColor(5));
"+28".SetDefaultColor(GetColor(3));
"-28".SetDefaultColor(GetColor(3));
"-75".SetDefaultColor(GetColor(5));
"-100".SetDefaultColor(GetColor(5));
ZeroLine.SetDefaultColor(GetColor(4));
def ADX = ADX (14);
def EMA60 = ExpAverage(close, 60);
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;

plot bullSignal = if trendExistence == 1 and direction == 1 and bullishCrossover then 1 else 0;
bullSignal.setPaintingStrategy(PaintingStrategy.ARROW_UP);

plot bearSignal = if trendExistence == 1 and direction == 3 and bearishCrossover then 1 else 0; bearSignal.setPaintingStrategy(PaintingStrategy.Boolean_ARROW_DOWN);
AddCloud(100, 75, color.green, color.green);
Addcloud (-100,-75, color.red, color.red);
Plot VZO_Dots = 100 * VP / TV;
VZO.setLineWeight(3);
VZO_Dots.setPaintingStrategy(PaintingStrategy.POINTS);
VZO_Dots.setLineWeight(3);
VZO.AssignValueColor(if VZO > 15 then color.green else if VZO > -5 then color.yellow else color.red);
VZO_Dots.AssignValueColor(if VZO > 15 then color.green else if VZO > -5 then color.yellow else color.red);
 
Last edited by a moderator:

BenTen

Administrative
Staff
VIP
This is based on the Volume Zone Oscillator. Here is the modified code.

Code:
# VZO
# TD Ameritrade IP Company, Inc. (c) 2011-2020
# Modified by BenTen at UseThinkScript.com
input length = 14;

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

def VZO = 100 * VP / TV;

input lv1 = 75;
input lv2 = -75;
input lv3 = 100;
input lv4 = -100;

def condition1 = VZO crosses below lv2;
def condition2 = VZO crosses below lv3;
def condition3 = VZO crosses above lv1;
def condition4 = VZO crosses above lv4;

plot bullish = if condition1 or condition2 then low else double.nan;
plot bearish = if condition3 or condition4 then high else double.nan;
bullish.setPaintingStrategy(PaintingStrategy.ARROW_UP);
bearish.setPaintingStrategy(PaintingStrategy.ARROW_DOWN);
 

Similar threads

Top