# Upside down Plots for indicator

#### agirlhasnoname42

##### Member
Hi, I'm trying to figure out if there's a way to code a defined plot item to reverse it's plot (line format), like look at the line produced from the plot upside down .. it will be handy for vix and put call ratio etc, for me it just makes more sense to look at them that way. It would be great if anyone has any advice, thanks, Misty

Solution
Is this what you're after?

Code:
``````#####################################################################
####### Tema on 2 period EMA of Buying and Selling Volume############

input Tema_BVlength = 8;
TEMA_BV.SetPaintingStrategy(PaintingStrategy.LINE);
TEMA_BV.SetDefaultColor(Color.PLUM);
TEMA_BV.SetLineWeight(1);

input Tema_SVlength = 8;
plot TEMA_SB = -(TEMA(BaseSellAvg, Tema_SVlength));

plot zero = 0;``````
I changed the colors around on my plot a bit... you know how to change them back to whatever you need.

Let me know if I'm not going down the right track with this.

-mashume
You can do something like this:
Code:
``````def x = close(symbol = "/VX");
plot inverse = -x;``````

perhaps that gets you moving in the right direction

-mashume

thanks, but would this work with a defined element that is not a symbol? I've made an average, derived from negative volume data, that I would like to plot upside down. Forgive the newbie question if that sounds silly

thanks, but would this work with a defined element that is not a symbol? I've made an average, derived from negative volume data, that I would like to plot upside down. Forgive the newbie question if that sounds silly
It should. You can invert anything you want. I just picked /VX for fun.
This one came out interesting:
Code:
``````declare upper;

def Data = close(symbol = "/VX");

def first_bar = if barNumber() == 1 then close else first_bar[1];
def first_data = if barNumber() == 1 then data else first_data[1];

def vx_range = highestAll(data) - lowestAll(Data);
def range = highestAll(HIGH) - lowestAll(Low);
def mult = range / vx_range;

plot x = -((Data - first_data) * mult) + (first_bar) ;``````

plots the /VX, upside down, starting at the same point as your main chart .

-mashume

I'd like to paste some code for you to see- I can't figure out how I would replace (symbol = "/VX") with the below defined item "TEMA_SV"

input Tema_SVlength = 17;
plot TEMA_SV = TEMA(BaseSellAvg, Tema_SVlength);
TEMA_SV.SetPaintingStrategy(PaintingStrategy.LINE);
TEMA_SV.SetDefaultColor(Color.BLACK);
TEMA_SV.SetLineWeight(2);

Here is the entire code for context. Thanks for any help or input!

Code:
``````####################################################################################

#Volume color coded by amount of volume on up-tick versus amount of volume on down-tick

declare lower;

def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def Buying = V * (C - L) / (H - L);
def Selling = V * (H - C) / (H - L);

# Selling Volume
plot SV = Selling;
SV.SetPaintingStrategy(PaintingStrategy.line);
SV.SetDefaultColor(Color.RED);
SV.HideTitle();
SV.HideBubble();
SV.SetLineWeight(3);
SV.hide();

# Note that Selling + Buying Volume = Volume.
plot BV =  volume;
BV.SetPaintingStrategy(PaintingStrategy.line);
BV.SetDefaultColor(Color.DARK_GREEN);
BV.HideTitle();
BV.HideBubble();
BV.SetLineWeight(3);
BV.hide();

#############################################################
# plot average of Buying and Selling Pressure

input avg1_len = 2;
input avg1_type =  AverageType.EXPONENTIAL;
def avg1 = MovingAverage(avg1_type, price1, avg1_len);

def price2 = Selling;
input avg2_len = 2;
input avg2_type =  AverageType.EXPONENTIAL;
def avg2 = MovingAverage(avg2_type, price2, avg2_len);

plot BaseSellAvg = avg2;
BaseSellAvg.SetDefaultColor(Color.red);
BaseSellAvg.hidebubble();
BaseSellAvg.hide();

#####################################################################
####### Tema on 2 period EMA of Buying and Selling Volume############

input Tema_BVlength = 17;
TEMA_BV.SetPaintingStrategy(PaintingStrategy.LINE);
TEMA_BV.SetDefaultColor(Color.Plum);
TEMA_BV.SetLineWeight(2);

input Tema_SVlength = 17;
plot TEMA_SV = TEMA(BaseSellAvg, Tema_SVlength);
TEMA_SV.SetPaintingStrategy(PaintingStrategy.LINE);
TEMA_SV.SetDefaultColor(Color.BLACK);
TEMA_SV.SetLineWeight(2);

####################################################################################
#Create an smoothed MA on Buying and Selling TEMAs for signal

input TemaMA_SellSignal_length = 2;
plot TemaMA_SellSignal = Average(TEMA_SV, TemaMA_SellSignal_length);
TemaMA_SellSignal.SetPaintingStrategy(PaintingStrategy.line);
TemaMA_SellSignal.SetDefaultColor(Color.BLACK);
TemaMA_SellSignal.SetLineWeight(1);

####################################################################################``````

ok. thanks for posting some code.

you can make the substitution like this:
Code:
``````input Tema_SVlength = 17;
def TEMA_SV_data = TEMA(BaseSellAvg, Tema_SVlength);
plot TEMA_SB = TEMA_SV_data;
TEMA_SV.SetPaintingStrategy(PaintingStrategy.LINE);
TEMA_SV.SetDefaultColor(Color.BLACK);
TEMA_SV.SetLineWeight(2);

def Data = -TEMA_SB;``````
I left your plot intact, though you may want to remove it. I changed your plot to a def so that I create a variable from it rather than a plot. I redid the plot in the next line in case you still want it. Otherwise you may remove it.

I defined Data as the negative of the TEMA_SB series. If you use the rest of my code, you will want to remove the negative in the def because it's in the plot x... line.

-mashume

I think I've completely botched it- I can't figure out what I'm doing wrong, complete thinkscript newbie here! Can you pls help me correct the code so it works? I don't mind having a plot for both since I can turn it off or hide the original easily. I used a tema 8 instead of 17, so that's what ur looking for there, thanks!

Code:
``````####################################################################################

#Volume color coded by amount of volume on up-tick versus amount of volume on down-tick

declare lower;

def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def Buying = V * (C - L) / (H - L);
def Selling = V * (H - C) / (H - L);

# Selling Volume
plot SV = Selling;
SV.SetPaintingStrategy(PaintingStrategy.line);
SV.SetDefaultColor(Color.RED);
SV.HideTitle();
SV.HideBubble();
SV.SetLineWeight(3);
SV.hide();

# Note that Selling + Buying Volume = Volume.
plot BV =  volume;
BV.SetPaintingStrategy(PaintingStrategy.line);
BV.SetDefaultColor(Color.DARK_GREEN);
BV.HideTitle();
BV.HideBubble();
BV.SetLineWeight(3);
BV.hide();

#############################################################
# plot average of Buying and Selling Pressure

input avg1_len = 2;
input avg1_type =  AverageType.EXPONENTIAL;
def avg1 = MovingAverage(avg1_type, price1, avg1_len);

def price2 = Selling;
input avg2_len = 2;
input avg2_type =  AverageType.EXPONENTIAL;
def avg2 = MovingAverage(avg2_type, price2, avg2_len);

plot BaseSellAvg = avg2;
BaseSellAvg.SetDefaultColor(Color.red);
BaseSellAvg.hidebubble();
BaseSellAvg.hide();

#####################################################################
####### Tema on 2 period EMA of Buying and Selling Volume############

input Tema_BVlength = 8;
TEMA_BV.SetPaintingStrategy(PaintingStrategy.LINE);
TEMA_BV.SetDefaultColor(Color.Plum);
TEMA_BV.SetLineWeight(1);

input Tema_SVlength = 8;
def TEMA_SV_data = TEMA(BaseSellAvg, Tema_SVlength);
plot TEMA_SB = TEMA_SV_data;

def Data = TEMA_SB;
def first_bar = if barNumber() == 1 then close else first_bar[1];
def first_data = if barNumber() == 1 then data else first_data[1];

def sb_range = highestAll(data) - lowestAll(Data);
def range = highestAll(HIGH) - lowestAll(Low);
def mult = range / sb_range;

plot x = -((Data - first_data) * mult) + (first_bar) ;

x.SetPaintingStrategy(PaintingStrategy.LINE);
x.SetDefaultColor(Color.BLACK);
x.SetLineWeight(2);

####################################################################################
#Create an smoothed MA on Buying and Selling TEMAs for signal

input TemaMA_SellSignal_length = 2;
plot TemaMA_SellSignal = Average(TEMA_SB, TemaMA_SellSignal_length);
TemaMA_SellSignal.SetPaintingStrategy(PaintingStrategy.line);
TemaMA_SellSignal.SetDefaultColor(Color.BLACK);
TemaMA_SellSignal.SetLineWeight(2);

####################################################################################``````

I'll try to take a look at it tomorrow.

sounds great, thanks so much for the help

Is this what you're after?

Code:
``````#####################################################################
####### Tema on 2 period EMA of Buying and Selling Volume############

input Tema_BVlength = 8;
TEMA_BV.SetPaintingStrategy(PaintingStrategy.LINE);
TEMA_BV.SetDefaultColor(Color.PLUM);
TEMA_BV.SetLineWeight(1);

input Tema_SVlength = 8;
plot TEMA_SB = -(TEMA(BaseSellAvg, Tema_SVlength));

plot zero = 0;``````
I changed the colors around on my plot a bit... you know how to change them back to whatever you need.

Let me know if I'm not going down the right track with this.

-mashume

yes, something like that, but maybe with the option to turn off and on the line and have the lines partially overlap like they do without the reversing .. if I take the line out will it work? I'm also interested in having the line at 50% of the volume (so for time period it would find highest and lowest plots of series and plot the line in middle with both plots overlapping.. not sure if that makes sense? Do you think that's possible or is it too complicated? Thank you for your help! I eventually want to figure out how to make them both into a kind of stochastic ob/os format because I think the signals might be faster but I'm not sure that's possible with TOS.

cheers, misty

87k+ Posts
166 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?