Scanner is not validating the condition for the entire set of bars

abhi

New member
I tried the below script in the Thinkorswim Scanner's thinkScript Editor to list the stocks whose 8EMA has not crossed over 21EMA over last 10 bars, but this is not giving me the expected result. Even if for one bar, the below condition is passing, the scanner is listing the stock. The scanner is not validating the condition for the entire set of 10 bars. Please correct me or provide me some pointers.

(MovAvgExponential("length" = 8)."AvgExp" crosses above MovAvgExponential("length" = 21)."AvgExp" ) is false within 10 bars
 
Last edited by a moderator:
Thanks BenTen for your response. Even "is less than" is not giving the correct result. The problem seems that the if scanner finds the condition to be true for any of the bars, then it is listing the stock. The scanner is not validating the condition for every bar in the set. I am not sure if there is any keyword that instructs the scanner to validate the condition over all the bars (not just one single bar).

MovAvgExponential("length" = 8)."AvgExp" is less than MovAvgExponential("length" = 21)."AvgExp" within 10 bars
 
@abhi what if you adjust the timeframe? Say you want to apply that condition on the 5 min chart.

10 bars on the 5min chart would be roughly 1 bar on the 1H chart. Try scanning for the same condition but within 1 bar on the 1HR chart. Hope that makes sense.
 
Code:
def MA0 = MovAvgExponential("length" = 8)."AvgExp" is less than MovAvgExponential("length" = 21)."AvgExp" ;
def MA1 = MovAvgExponential("length" = 8)."AvgExp"[1] is less than MovAvgExponential("length" = 21)."AvgExp"[1] ;
def MA2 = MovAvgExponential("length" = 8)."AvgExp"[2] is less than MovAvgExponential("length" = 21)."AvgExp"[2] ;
def MA3 = MovAvgExponential("length" = 8)."AvgExp"[3] is less than MovAvgExponential("length" = 21)."AvgExp"[3] ;
def MA4 = MovAvgExponential("length" = 8)."AvgExp"[4] is less than MovAvgExponential("length" = 21)."AvgExp"[4] ;
def MA5 = MovAvgExponential("length" = 8)."AvgExp"[5] is less than MovAvgExponential("length" = 21)."AvgExp"[5] ;
def MA6 = MovAvgExponential("length" = 8)."AvgExp"[6] is less than MovAvgExponential("length" = 21)."AvgExp"[6] ;
def MA7 = MovAvgExponential("length" = 8)."AvgExp"[7] is less than MovAvgExponential("length" = 21)."AvgExp"[7] ;
def MA8 = MovAvgExponential("length" = 8)."AvgExp"[8] is less than MovAvgExponential("length" = 21)."AvgExp"[8] ;
def MA9 = MovAvgExponential("length" = 8)."AvgExp"[9] is less than MovAvgExponential("length" = 21)."AvgExp"[9] ;
def MA10 = MovAvgExponential("length" = 8)."AvgExp"[10] is less than MovAvgExponential("length" = 21)."AvgExp"[10] ;

plot scan = MA0 and MA1 and MA2 and MA3 and MA4 and
            MA5 and MA6 and MA7 and MA8 and MA9 and MA10 ;

Copy and Paste this code as a study and in the scanner put scan equals true
 

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
266 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