How to include in a Scan an indicator condition of a specific stock (SPY)?

AJSeidcheck

New member
Hi,

I'm wondering how to include a specific criteria into thinkscript code for a ThinkOrSwim scan. I want to include the condition of a certain indicator for the ticker "SPY" in my scan, which is scanning for stocks that meet a certain criteria.

For example, the scan will only return any results if SPY's 8 EMA is over the 21 EMA.

Let me know if this is possible, and how to code this 'specific stock indicator criteria' into the scan criteria. Thanks!

-Alex
 
Solution
Untested, typed here freehand, and without further details, it should be something like this:

Def SpyCondition = MoveAvgExponential(Close("SPY"),8) > MoveAvgExponential(Close("SPY"),21);
Plot Scan = OtherConditions and SpyCondition;
Untested, typed here freehand, and without further details, it should be something like this:

Def SpyCondition = MoveAvgExponential(Close("SPY"),8) > MoveAvgExponential(Close("SPY"),21);
Plot Scan = OtherConditions and SpyCondition;
 
Solution

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

Hey Joshua,

It's giving me the following error, I've also tried to modify it a bit, but it's still throwing errors. Any ideas on how to remove the bugs?

1st iteration:
Def SpyCondition = MoveAvgExponential(Close("SPY"),8) > MoveAvgExponential(Close("SPY"),21);
Plot Scan = OtherConditions and SpyCondition;

No such function: MoveAvgExponential at 1:20
No such function: MoveAvgExponential at 1:20
No such function: MoveAvgExponential at 1:57
No such function: MoveAvgExponential at 1:57
No such function: MoveAvgExponential at 1:20
Incompatible parameter: Close at 1:5
No such function: MoveAvgExponential at 1:20
Incompatible parameter: 8 at 1:5
No such function: MoveAvgExponential at 1:57
Incompatible parameter: Close at 1:5
No such function: MoveAvgExponential at 1:57
Incompatible parameter: 21 at 1:5
Expected double
No such variable: OtherConditions at 3:13
No such function: MoveAvgExponential at 1:20
No such function: MoveAvgExponential at 1:20
No such function: MoveAvgExponential at 1:57
No such function: MoveAvgExponential at 1:57
No such function: MoveAvgExponential at 1:20
Incompatible parameter: Close at 1:5


2nd iteration:
Def SpyCondition = MoveAvgExponential(Close="SPY","length"=8)."AvgExp" is greater than MoveAvgExponential(Close="SPY","length"=21)."AvgExp";
Plot Scan = SpyCondition;

Errors:
No such function: MoveAvgExponential at 1:21
No such function: MoveAvgExponential at 1:21
No such function: MoveAvgExponential at 1:91
No such function: MoveAvgExponential at 1:91
No such function: MoveAvgExponential at 1:21
Incompatible parameter: "SPY" at 1:5
No such function: MoveAvgExponential at 1:21
Incompatible parameter: 8 at 1:5
No such function: MoveAvgExponential at 1:91
Incompatible parameter: "SPY" at 1:5
No such function: MoveAvgExponential at 1:91
Incompatible parameter: 21 at 1:5
Expected double
Invalid statement: Unexpected part of function call at 1:64
Invalid statement: Unexpected part of function call at 1:135
No such function: MoveAvgExponential at 1:21
No such function: MoveAvgExponential at 1:21
No such function: MoveAvgExponential at 1:91
No such function: MoveAvgExponential at 1:91
No such function: MoveAvgExponential at 1:21


Let me know if you can tell what's wrong, thanks!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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