Stacked Moving Averages For ThinkOrSwim

is there a way to get an arrow on mobile when 3 ema's are stacked correctly?

Here ya go:
Ruby:
def stackedUp = Average(close,10) is greater than Average(close,20)
and Average(close,20) is greater than Average(close,50);

def stackedDn = Average(close,10) is less than Average(close,20)
and Average(close,20) is less than Average(close,50);



AddLabel(yes, " Stacked ",
    if stackedUp then Color.GREEN else if stackedDn then Color.RED else Color.GRAY);
what is the code to scan when this occurs?
 
Last edited by a moderator:
is there a way to get an arrow on mobile when 3 ema's are stacked correctly?


what is the code to scan when this occurs?
This version can be used for mobile and scanner.
To reference a study in the scanner:
https://usethinkscript.com/threads/how-to-use-thinkorswim-stock-hacker-scans.284/
Ruby:
def stackedUp = Average(close,10) is greater than Average(close,20)
and Average(close,20) is greater than Average(close,50);

def stackedDn = Average(close,10) is less than Average(close,20)
and Average(close,20) is less than Average(close,50);



plot ArrowUP = stackedUP ;
ArrowUP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
ArrowUP.SetDefaultColor(color.cyan) ;
ArrowUP.SetLineWeight(1);

plot ArrowDN = stackedDN;
ArrowDN.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
ArrowDN.SetDefaultColor(color.magenta) ;
ArrowDN.SetLineWeight(1);
hXqTSvj.png
 
is there a way to get an arrow on mobile when 3 ema's are stacked correctly?


what is the code to scan when this occurs?
i'm getting an error that no label so I deleted that but it says at least one plot needs to be defined.
what im trying to accomplish is an alert when they are stacked, I thought if I did it as a scan it would alert when it happened in my scan.
 
i'm getting an error that no label so I deleted that but it says at least one plot needs to be defined.
what im trying to accomplish is an alert when they are stacked, I thought if I did it as a scan it would alert when it happened in my scan.
Actually there are two plots defined in the above script so your error is not possible.
And as you can see it works in the above image just fine with no errors.
And there is no label, so there can be no label error message.

Maybe the problem lies with your cutting and pasting of the above script into a new study?
https://usethinkscript.com/threads/how-to-import-existing-thinkscript-code-on-thinkorswim.10/
or
You didn't follow these instructions when setting up your scan?
https://usethinkscript.com/threads/how-to-use-thinkorswim-stock-hacker-scans.284/

For Alerts:
There are scanned watchlist alerts which alert whenever the results of the scan changes.
These alerts can be 3min delayed. They can have custom sounds, they can be sent to phone/email, if you have notifications turned on in the app setup.
https://tlc.thinkorswim.com/center/howToTos/thinkManual/Scan/Stock-Hacker#:~:text=Scan results are,scan results change…
 
Last edited:
Actually there are two plots defined in the above script so your error is not possible.
And as you can see it works in the above image just fine with no errors.
And there is no label, so there can be no label error message.

Maybe the problem lies with your cutting and pasting of the above script into a new study?
https://usethinkscript.com/threads/how-to-import-existing-thinkscript-code-on-thinkorswim.10/
or
You didn't follow these instructions when setting up your scan?
https://usethinkscript.com/threads/how-to-use-thinkorswim-stock-hacker-scans.284/

For Alerts:
There are scanned watchlist alerts which alert whenever the results of the scan changes.
These alerts can be 3min delayed. They can have custom sounds, they can be sent to phone/email, if you have notifications turned on in the app setup.
https://tlc.thinkorswim.com/center/howToTos/thinkManual/Scan/Stock-Hacker#:~:text=Scan results are,scan results change…
Thank you!!
 
Hi . I use this bullish stacked EMA scan code.
I'd like to scan also for bearish stacked EMA.
Can someone please edit the code ? Thanks !

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


Or what would you use instead ?
 
Last edited by a moderator:
Hi . I use this bullish stacked EMA scan code.
I'd like to scan also for bearish stacked EMA.
Can someone please edit the code ? Thanks !

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

To change from bullish to bearish; change the 'greater than' signs to 'less than' signs.

I am not sure that this script provides any significant value. No, I have no other suggestions.
I have never seen any research or articles that stacked bearish EMA's provide a good exit point or a good place to short.

But you should do what works for you,
Come back if you find this useful and explain how.

MovAvgExponential("length" = 8)."AvgExp" is less than MovAvgExponential("length" = 21)."AvgExp" and MovAvgExponential("length" = 21)."AvgExp" < MovAvgExponential("length" = 34)."AvgExp" and MovAvgExponential("length" = 34)."AvgExp" < MovAvgExponential("length" = 55)."AvgExp" and MovAvgExponential("length" = 55)."AvgExp" < MovAvgExponential("length" = 89)."AvgExp"
 
Last edited:
Here is my EMA_Stack... Watch it and see if it will get you most of the way to where you want to be...
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);
TOS says @ 13:1 AddLabel is not useable in this context
 
Last edited by a moderator:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
358 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