MA cross question

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!!
 
Are you talking about the 8 moving average and the 26 moving average? Do you want to see arrows when they crossover?
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

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:
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);

U4SMZjd.png


HTH
 
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.
 
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);

U4SMZjd.png


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?
 
  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 ################################
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
326 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

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?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top