Making a 13 over 30 Crossover Scan

leonrossi

New member
Hi All,
I'm new to thinkscript. I would like to create a scan to detect EMA 13 over 30 crossover on the hourly time frame in TOS. I would also like to incorporate the parameter of a stock in an uptrend or downtrend for about 2 weeks before they cross over. I have tried to do this in TOS but i do not get good results. The part that I struggle with is how to capture the stock either in an uptrend or downtrend for about 2 weeks. The idea behind this scan is to spot a momentum stock when it's reversing. Does anyone know how to do this? any help would be greatly appreciated.
 
Isn't max_bars_since_cross only for the right side of the cross-over? I.e. Bars since the 2 MAs crossed <= 7? I love that the code accommodates for this. Reducing it below 7 will impact the results but more to do with the right side of the cross-over vs the left which is what I am unable to solve for. Not sure if that makes sense?
I get what you're pointing out. I had to look at the code a bit to figure out what I did . . . So, (I'll use the cross down side as an example) what the code is doing is looking for a count of at least "X" amount of bars since previous cross up, regardless whether or not there has been a crossover down since; the count apparently does not reset until after a new cross upwards, when it starts counting from 1 again. What filters out the stocks from that point is the condition that there must have been a crossover downwards within 7 bars. Taking MPWR as an example, it has been at least 49 bars since the last crossover upwards; it also is within the 7 bars since the last crossover downwards, so it appears on the scan. I probably should revisit that code when I get time and try to make it better.
 

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

@Pensar This is very impressive for swing trading imho.

Can u script a scan for a cross-over (upward/uptrend) of EMA 9 crossing over/above 200 & reconfirm uptrend using EMA 18/200 (uptrend) crossover as well. Using 1hr agrre, I like 7bar per day idea too.

EG: I am looking at CSX (it showed up on the scanner listed above), the Cross EMas (9xover200, 21xover200, 34xover200) happened on 11/2 monday & price was 80/sh & its 90/shr now. However, I don't know if uptrend would continue at same rate/trajectory (er 12/29) but I will watch for a dip to enter the trade. If I had known of these 3 EMAS (9,21,34) crossing above 200 in a single day on 1hr agg - I would have entered the trade on 11/2 & wouldn't have considered to enter 2 wks later, but will look for a dip now

I am also using your watch list column from diff thread listed below along with the scanner to guide me. Thanks in advance

Code:
#choose your aggregation above

def ema1 = expaverage(close,9);
def ema2 = expaverage(close,26);
def crossup = ema1 > ema2;
def crossdn = ema1 < ema2;

def countup = if crossup and !crossup[1] then 1 else countup[1]+1;
def countdn = if crossdn and !crossdn[1] then 1 else countdn[1]+1;

addlabel(1, if crossup then "Buy,  " + countup
         else if crossdn then "Sell,  " + countdn
         else "Equal", color.black);
assignbackgroundcolor(if crossup then color.green
                      else if crossdn then color.red
                      else color.gray);
 
Last edited:
So if you'd like to add a condition to check the price against high of day, what would that code look like? I searched for it on the forum, couldn't find it. Any suggestions?
I don't know - I think there's a script by the name of "trend reversal" or "super indicator" which plots bubbles for high & low of the day..check it out
 
@mansor This is easy to create in the scanner Condition Wizard, no custom script necessary. Just choose your MovingAvgExponential crossings and then type in the number of bars in which you want the condition to be true into the "within _____ bars" box below.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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