Scan for stocks whose price is between two MAs

dhman06

Member
Hello all,

I would like to create a scan that lists all stocks whose price is within two MAs: current price is between the High of 3EMA and Close of 8EMA

Is there a way to create that sort of scan in TOS? I wish I could code that up, but I'm not smart enough. Any help would be greatly appreciated.
 
Hello all,

I would like to create a scan that lists all stocks whose price is within two MAs: current price is between the High of 3EMA and Close of 8EMA

Is there a way to create that sort of scan in TOS? I wish I could code that up, but I'm not smart enough. Any help would be greatly appreciated.
Here is a start...

Code:
plot ema2Band = close between EMA2("data" = CLOSE, "prefetch" = 3, "smoothing factor" = 0.1) and EMA2("data" = CLOSE, "prefetch" = 8, "smoothing factor" = 0.1);
 
VsojBDi.jpg


Essentially what I'm trying to do is catch stocks that have last prices in between high of 3EMA and close of 8EMA. For example: price here is 214.57, 3EMA high is 217.62 and 8EMA close is 212.28
 
Last edited:
Here is a start...

Code:
plot ema2Band = close between EMA2("data" = CLOSE, "prefetch" = 3, "smoothing factor" = 0.1) and EMA2("data" = CLOSE, "prefetch" = 8, "smoothing factor" = 0.1);

What does the smoothing factor do?

Also should I be using prefetch? It seems like it refers to historical data. I'm not sure how it will be helpful
 
So, this is what I've got so far:

Code:
input fastprice = high;
input fastlength = 3;
input slowprice = close;
input slowlength = 8;
input averageType = AverageType.EXPONENTIAL;

plot fastma = MovingAverage(averageType,fastprice, fastlength);
plot slowma = MovingAverage(averageType,slowprice,slowlength);

but I can't figure out how to spot stock that are in between high of 3EMA and close of 8EMA. Any help will be really appreciated
 
I took a stab at it on TOS scanner function and came up with this. Is someone can confirm if I did this right or suggest a better way to improve it to match my goal that'll be greatly appreciated

lttb5Lb.jpg
 
Please post the entire block of Thinkscript code by switching to the Thinkscript Editor mode and doing a Copy & Paste within code tags via </> from the toolbar... We need to see the entire code block to give an accurate answer... We can also test it for errors...
 
Please post the entire block of Thinkscript code by switching to the Thinkscript Editor mode and doing a Copy & Paste within code tags via </> from the toolbar... We need to see the entire code block to give an accurate answer... We can also test it for errors...

I didn't write any code. I added study filters. Is there anyway to convert those to codes?
 
Yes, as I described in my previous post you can access the code using the Thinkscript Editor button... 💡

Found what you were talking about. Another new thing that I've learned. Thank you. So I have this ---

MovAvgExponential("price" = HIGH, "length" = 3)."AvgExp" is greater than or equal to MovAvgExponential("length" = 8)."AvgExp" within 2 bars and MovAvgExponential("length" = 8)."AvgExp" is greater than MovAvgExponential("length" = 17)."AvgExp" within 2 bars and MovAvgExponential("price" = HIGH, "length" = 3)."AvgExp" is greater than close and MovAvgExponential("length" = 8)."AvgExp" is less than close("priceType" = PriceType.LAST)

And I combined this with 50period simple volume for the last 4 bars:

VolumeAvg()."VolAvg" is greater than 350000 within 4 bars
 
@dhman06

There you go...!!! I love it when people take nudges and hints and expound upon them in a learning manner... I'm sure it feels much more rewarding than just having results handed to you... (y)

Keep at it... ;)
 
@dhman06

Well, I included the VolumeAvg() with your other criteria and get 746 results... Not sure if you want to filter further or not but it produces results... The code below was copied from the Thinkscript Editor panel and is editable using the Conditional Wizard...

Code:
MovAvgExponential("price" = high, "length" = 3)."AvgExp" is greater than or equal to MovAvgExponential("length" = 8)."AvgExp" within 2 bars and MovAvgExponential("length" = 8)."AvgExp" is greater than MovAvgExponential("length" = 17)."AvgExp" within 2 bars and MovAvgExponential("price" = high, "length" = 3)."AvgExp" is greater than close and MovAvgExponential("length" = 8)."AvgExp" is less than close("priceType" = PriceType.LAST) and VolumeAvg()."VolAvg" is greater than 350000 within 4 bars
 
@dhman06

Well, I included the VolumeAvg() with your other criteria and get 746 results... Not sure if you want to filter further or not but it produces results... The code below was copied from the Thinkscript Editor panel and is editable using the Conditional Wizard...

Code:
MovAvgExponential("price" = high, "length" = 3)."AvgExp" is greater than or equal to MovAvgExponential("length" = 8)."AvgExp" within 2 bars and MovAvgExponential("length" = 8)."AvgExp" is greater than MovAvgExponential("length" = 17)."AvgExp" within 2 bars and MovAvgExponential("price" = high, "length" = 3)."AvgExp" is greater than close and MovAvgExponential("length" = 8)."AvgExp" is less than close("priceType" = PriceType.LAST) and VolumeAvg()."VolAvg" is greater than 350000 within 4 bars

Is it possible to take your code and make an indicator? For example, an arrow sign would show up if the criteria is met and I can set an alert for that arrow?
 

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