EMA-SMA-VWAP Stacked Indicator for ThinkorSwim

Partner

New member
VIP
Can anyone help to create a script to identify the ticker when stacking of VWAP, 200 SMA, 9 EMA, 21 SMA, 34 EMA & 89 EMA are together - Timeframe 3 mins. (Pls note, we already have the script in the forum when 8EMA>21EMA>34EMA>55EMA>89EMA. However, looking for a script when they are merged together irrespective of the order). What I have observed when they merged together we normally see a big move in a ticker on either side. Below are two examples from Friday, 4th Dec.

And if possible to add - if the price is above VWAP the signal turns to Green and if the price is below VWAP the signal turns to Red.

Hw9WuEh.png
JcXP7Fu.png
 
Last edited:

rad14733

Well-known member
VIP
@Partner I think you'll find that if you are going to get a big move that the averages will be properly stacked in order... I have been running an EMA Stack for a week or two and virtually all major moves have stacked MA's... Let's not complicate things needlessly...

Here is my EMA_Stack... Watch it and see if it will get you most of the way to where you want to be... The only thing I want to add is to know when the averages are squeezed/converged but I'm running my TTM_Squeeze_Clouds for that presently...

Ruby:
def stackedUp = MovAvgExponential("length" = 8)."AvgExp" is greater than MovAvgExponential("length" = 21)."AvgExp"
and MovAvgExponential("length" = 21)."AvgExp" is greater than MovAvgExponential("length" = 34)."AvgExp"
and MovAvgExponential("length" = 34)."AvgExp" is greater than MovAvgExponential("length" = 55)."AvgExp"
and MovAvgExponential("length" = 55)."AvgExp" is greater than MovAvgExponential("length" = 89)."AvgExp";


def stackedDn = MovAvgExponential("length" = 8)."AvgExp" is less than MovAvgExponential("length" = 21)."AvgExp"
and MovAvgExponential("length" = 21)."AvgExp" is less than MovAvgExponential("length" = 34)."AvgExp"
and MovAvgExponential("length" = 34)."AvgExp" is less than MovAvgExponential("length" = 55)."AvgExp"
and MovAvgExponential("length" = 55)."AvgExp" is less than MovAvgExponential("length" = 89)."AvgExp";


AddLabel(yes, " Stacked ", if stackedUp then Color.GREEN else if stackedDn then Color.RED else Color.GRAY);

8|21|34|55|89 EMA Stack

ReGNbia.jpg
 
Last edited:

VenB

New member
VIP
@rad14733 Thank you. Can you help to format this code for scanning?

Thank you. Some times moving averages doesn't actually line up/down, but you will see a big move when they are very close to each other. Please see if you can build a code with some percentage of distance between the moving averages. Thank you.
 
Last edited by a moderator:

rad14733

Well-known member
VIP
@rad14733 I added the above code and all I get to display is a stacked label at the top, nothing else? any ideas why it doesn't look like your screenshot?
Ha...!!! That's because all I posted was the code to produce a Stacked Chart Label, not the EMA's themselves... If that's what you're looking for I can post the code but presently I use three Studies to get the five EMA's... I had been just running the three but added two more EMA's the other day just to see how they all worked together...
 

Shrum

Member
Ha...!!! That's because all I posted was the code to produce a Stacked Chart Label, not the EMA's themselves... If that's what you're looking for I can post the code but presently I use three Studies to get the five EMA's... I had been just running the three but added two more EMA's the other day just to see how they all worked together...
So you don’t have the arrow plotting automatically? Thanks for the reply
 

rad14733

Well-known member
VIP
So you don’t have the arrow plotting automatically? Thanks for the reply
The arrows actually come from two copies of the TOS MovAvgCrossover Study... I am currently experimenting and testing which is why it takes a total of five Studies, my 3-EMA, two MovAvgCrossover's, a 34 EMA, and an 89 EMA... I haven't combined everything together as yet... This is a prime example of me not getting my own coding done due to working on code for members here... :confused:
 

rad14733

Well-known member
VIP
Can the script also me modified to display StackUp and StackDown watchlist display column?

Here is my actual Watchlist Column code... It's almost identical to the code above... I just use colors without text because I need the screen real estate for other things... Green = StackedUp, Red = StackedDown, Gray = NotStacked...

Ruby:
#EMA_Stack
#Used to indicate that 8, 21, 34, 55, 89  EMA's are ALL stacked trend-wise
#Created by rad14733 for usethinkscript.com
#v1.0 2021-01-02

def stackedUp = MovAvgExponential("length" = 8)."AvgExp" is greater than MovAvgExponential("length" = 21)."AvgExp"
and MovAvgExponential("length" = 21)."AvgExp" is greater than MovAvgExponential("length" = 34)."AvgExp"
and MovAvgExponential("length" = 34)."AvgExp" is greater than MovAvgExponential("length" = 55)."AvgExp"
and MovAvgExponential("length" = 55)."AvgExp" is greater than MovAvgExponential("length" = 89)."AvgExp";


def stackedDn = MovAvgExponential("length" = 8)."AvgExp is less than MovAvgExponential("length" = 21)."AvgExp"
and MovAvgExponential("length" = 21)."AvgExp" is less than MovAvgExponential("length" = 34)."AvgExp"
and MovAvgExponential("length" = 34)."AvgExp" is less than MovAvgExponential("length" = 55)."AvgExp"
and MovAvgExponential("length" = 55)."AvgExp" is less than MovAvgExponential("length" = 89)."AvgExp";

def state = if stackedUp then 1 else if stackedDn then -1 else 0;

AddLabel(yes, state, if stackedUp then Color.DARK_GREEN else if stackedDn then Color.DARK_RED else Color.DARK_GRAY);

AssignBackgroundColor(if stackedUp then Color.DARK_GREEN else if stackedDn then Color.DARK_RED else Color.DARK_GRAY);
 

Similar threads

Top