Simple visual indicator for a line over another line

V

vro3

Member
Hey guys! I've really fallen in love with the 8 over the 26 as a buy and opposite for sell.
So many times, the lines are so close - I have to zoom in super close to see whats on top. There's gotta be a better way.
I don't know what, but is there a dead simple visual way to tell me if one is over the other?
Ideas I've had are a "yes or no" in the top left. a way to just change the background of the lower indicator. an alert? something dead simple?

Thanks!!
 
BenTen

BenTen

Administrative
Staff
VIP
Are you talking about the 8 moving average and the 26 moving average? Do you want to see arrows when they crossover?
 
V

vro3

Member
Are you talking about the 8 moving average and the 26 moving average? Do you want to see arrows when they crossover?
actually - no. IT's the EMA8 and a VWMA26.
I'd love something as simple as "is the 8 over the 26 Y or N"
or, any other concept that I don't know about. :) would be awesome in a WL indicator too.

is that possible? any ideas?
 
Last edited:
V

vro3

Member
input length = 26;
def vwma = sum(volume * close, length) / sum(volume, length);
plot Value = vwma;

This is my VWMA script.
 
MerryDay

MerryDay

Member
VIP
There are several ways to accomplish what you need and because I have nothing better to do while I wait for my brownies to finish baking,
I wrote up some samples for you:

Code:
plot ema8 = ExpAverage(close, 8);
plot vwma26 = Sum(volume * close, 26) / Sum(volume, 26);
plot MAcrossUP = ema8 crosses above vwma26 ;
plot MAcrossDN = ema8 crosses below vwma26 ;

#this will make your EMA line change color whenever it is above your volume
ema8.assignValueColor(if ema8 > vwma26 then color.blue else color.magenta);
ema8.setlineWeight(2);

#this will give you an arrow whenever your EMA crosses above your volume
MAcrossUP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
MAcrossUP.SetLineWeight(2);
MAcrossUP.SetDefaultColor(color.blue) ;

#this will give you an arrow whenever your EMA crosses below your volume
MAcrossDN.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_down);
MAcrossDN.SetLineWeight(2);
MAcrossDN.SetDefaultColor(color.magenta) ;

#this will give you a cloud of colors: green when above, pink when below
AddCloud(ema8, vwma26, color.green, color.pink);


HTH
 
V

vro3

Member
Soooo, I'm really happy the script, but please tell me more about these brownies.

No, but seriously, thank you so much! This is exactly the start I was looking for.
I'll put this into use and see how it helps.
 
V

vro3

Member
SO - I'm not sure WHAT/WHY, but i can see there's a difference between our EMA8 lines. I tried putting my code into your plot and it didnt work.
But also - i'm not sure which EMA8 is more true!

input price = close;
input length = 8;
input highLowLength = 10;

def multiplier1 = 2 / (length + 1);
def multiplier2 = AbsValue((close - Lowest(low, highLowLength)) - (Highest(high, highLowLength) - close)) / (Highest(high, highLowLength) - Lowest(low, highLowLength));
def alpha = multiplier1 * (1 + multiplier2);
def ma = CompoundValue(1, ma[1] + alpha * (price - ma[1]), Average(price, length));

plot AEMA = ma;
AEMA.SetDefaultColor(GetColor(1));
is my code.
It seems to be a little quicker, but i dont know that it means its better. It's just what I've been using. any input on THAT?

Also, I'm not sure what they're called - but the data boxes that live up in the top left corner of charts. Could that be used to display a simple "yes / no" as well?

THANK YOU!
There are several ways to accomplish what you need and because I have nothing better to do while I wait for my brownies to finish baking,
I wrote up some samples for you:

Code:
plot ema8 = ExpAverage(close, 8);
plot vwma26 = Sum(volume * close, 26) / Sum(volume, 26);
plot MAcrossUP = ema8 crosses above vwma26 ;
plot MAcrossDN = ema8 crosses below vwma26 ;

#this will make your EMA line change color whenever it is above your volume
ema8.assignValueColor(if ema8 > vwma26 then color.blue else color.magenta);
ema8.setlineWeight(2);

#this will give you an arrow whenever your EMA crosses above your volume
MAcrossUP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
MAcrossUP.SetLineWeight(2);
MAcrossUP.SetDefaultColor(color.blue) ;

#this will give you an arrow whenever your EMA crosses below your volume
MAcrossDN.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_down);
MAcrossDN.SetLineWeight(2);
MAcrossDN.SetDefaultColor(color.magenta) ;

#this will give you a cloud of colors: green when above, pink when below
AddCloud(ema8, vwma26, color.green, color.pink);


HTH
day one. LOVE the cloud. that is definately a great help. The arrows get lost a little in the lines / candle sticks. working on the right color scheme for those. I didn't set the colors well for the color change. (im also slightly color blind, which is part of my need for visual help with this.! small colors just become a blur for me!)

Either way - this is such a help. Can I turn this into a WL category too? Say, white if over 26 and black if under?
 
MerryDay

MerryDay

Member
VIP
  1. You have the definition of an AEMA. You can read more about AEMA's here: https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/A-B/AdaptiveEMA.html. I don't use them and couldn't find any in-depth discussions about them on this site. If it is giving you the results you want, then continue to use it.
  2. If you are having difficulty viewing the colors, they can be changed to suit your needs. A list of colors available are here: https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/Color
  3. I updated your study w/ your version of AEMA instead of the EMA.
  4. Another way to highlight your moving average crosses is to change the candle color. I added an example at the end of this code:
Code:
# Put a '#' at the beginning of any of the scenarios you don't want to use.  Or just delete those lines.
# AEMA - VWMA crossover study
# compiled by vro3
input price = close;
input length = 8;
input highLowLength = 10;

def multiplier1 = 2 / (length + 1);
def multiplier2 = AbsValue((close - Lowest(low, highLowLength)) - (Highest(high, highLowLength) - close)) / (Highest(high, highLowLength) - Lowest(low, highLowLength));
def alpha = multiplier1 * (1 + multiplier2);
def ma = CompoundValue(1, ma[1] + alpha * (price - ma[1]), Average(price, length));

plot AEMA = ma;
AEMA.SetDefaultColor(GetColor(1));
plot vwma26 = Sum(volume * close, 26) / Sum(volume, 26);
# ########################################################
# charting and formatting:

#this will make your EMA line change color whenever it is above your volume
AEMA.AssignValueColor(if AEMA > vwma26 then Color.BLUE else Color.MAGENTA);
AEMA.SetLineWeight(2);

#this will give you an arrow whenever your EMA crosses above your volume
plot MAcrossUP = AEMA crosses above vwma26 ;
MAcrossUP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
MAcrossUP.SetLineWeight(2);
MAcrossUP.SetDefaultColor(Color.BLUE) ;

#this will give you an arrow whenever your EMA crosses below your volume
plot MAcrossDN = AEMA crosses below vwma26 ;
MAcrossDN.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
MAcrossDN.SetLineWeight(2);
MAcrossDN.SetDefaultColor(Color.MAGENTA) ;

#this will give you a cloud of colors: green when above, pink when below
AddCloud(AEMA, vwma26, Color.GREEN, Color.PINK);

#############################  NEW --- Changes candle color ################################
#this will change the color of the candles on your chart each time your averages cross:
AssignPriceColor(if AEMA crosses above vwma26 then Color.YELLOW else if AEMA crosses below vwma26 then Color.MAGENTA else Color.CURRENT);
#############################  NEW --- Changes candle color ################################
 
V

vro3

Member
I dont know who you are, but I am incredibly thankful for you!
 

Similar threads

Top