Scan for ema above high/low first bar of day

nrod21

New member
Hi, I'm looking for a way to scan for a moving average when it crosses the high or low of the opening 5 min bar.

I can figure out how to setup a scan for the high to cross a moving average but i can't seem to figure out how to make the first candle the trigger bar if that makes sense.

Kind of like an ORB scan but with moving averages instead of just price

I hope this makes sense...
 
Solution
Hi, I'm looking for a way to scan for a moving average when it crosses the high or low of the opening 5 min bar.

I can figure out how to setup a scan for the high to cross a moving average but i can't seem to figure out how to make the first candle the trigger bar if that makes sense.

Kind of like an ORB scan but with moving averages instead of just price

I hope this makes sense...

here is an upper study to experiment with
it can be converted to a lower or scan

using an average for crossing , greatly delays signals. by the time you see this , the move is probably over


Code:
#orb_levels_ema_cross

#ema_cross_openbar_hilo

#https://usethinkscript.com/threads/scan-for-ema-above-high-low-first-bar-of-day.20090/
#Scan for ema...
Hi, I'm looking for a way to scan for a moving average when it crosses the high or low of the opening 5 min bar.

I can figure out how to setup a scan for the high to cross a moving average but i can't seem to figure out how to make the first candle the trigger bar if that makes sense.

Kind of like an ORB scan but with moving averages instead of just price

I hope this makes sense...

here is an upper study to experiment with
it can be converted to a lower or scan

using an average for crossing , greatly delays signals. by the time you see this , the move is probably over


Code:
#orb_levels_ema_cross

#ema_cross_openbar_hilo

#https://usethinkscript.com/threads/scan-for-ema-above-high-low-first-bar-of-day.20090/
#Scan for ema above high/low first bar of day
#nrod21  12/28

# I'm looking for a way to scan for a moving average when it crosses the high or low of the opening 5 min bar.

#I can figure out how to setup a scan for the high to cross a moving average but i can't seem to figure out how to make the first candle the trigger bar if that makes sense.

#Kind of like an ORB scan but with moving averages instead of just price

#declare lower;

def na = Double.NaN;
def bn = BarNumber();

def daystart = 0930;
input orb_end = 0935;
def dayend = 1600;
def d = GetDay();
def newday = d != d[1];
def istoday = d == GetLastDay();

def orbtime = if SecondsFromTime(daystart) >= 0 and SecondsTillTime(orb_end) > 0 then 1 else 0;
def daytime = if SecondsFromTime(daystart) >= 0 and SecondsTillTime(dayend) > 0 then 1 else 0;
def daystartbar = (SecondsFromTime(daystart) == 0);
def orbendbar = (SecondsFromTime(orb_end) == 0);


def orbhi = if daystartbar then high
 else if orbtime then Max(high, orbhi[1])
 else if daytime then orbhi[1]
 else 0;

def orblo = if daystartbar then low
 else if orbtime then Min(low, orblo[1])
 else if daytime then orblo[1]
 else 0;

input avg1_type = AverageType.EXPONENTIAL;
input avg1_length = 20;
def avg1 = MovingAverage(avg1_type, close, avg1_length );

def xup = avg1 crosses above orbhi;
def xdwn = avg1 crosses below orblo;

# for use as a scanner,  (or lower for testing)
#   enable this code line 
#plot z = xup or xdwn;


#-------------------

# for use as a scanner,  delete everything after this line

# upper study code

addverticalline(xup, "up", color.green);
addverticalline(xdwn, "dwn", color.red);


input show_avg1_line = yes;
plot zavg1 = if show_avg1_line then avg1 else na;
zavg1.SetDefaultColor(Color.CYAN);
zavg1.SetLineWeight(1);
zavg1.HideBubble();


input show_orb_levels = yes;
plot zorbhi = if show_orb_levels and orbhi > 0 then orbhi else na;
zorbhi.SetDefaultColor(Color.CYAN);
zorbhi.SetLineWeight(1);
zorbhi.HideBubble();

plot zorblo = if show_orb_levels and orblo > 0 then orblo else na;
zorblo.SetDefaultColor(Color.CYAN);
zorblo.SetLineWeight(1);
zorblo.HideBubble();


input show_dots = yes;
plot zdothi = if show_dots and xup then orbhi else na;
zdothi.SetPaintingStrategy(PaintingStrategy.POINTS);
zdothi.SetDefaultColor(Color.yellow);
zdothi.SetLineWeight(3);
zdothi.HideBubble();

plot zdotlo = if show_dots and xdwn then orblo else na;
zdotlo.SetPaintingStrategy(PaintingStrategy.POINTS);
zdotlo.SetDefaultColor(Color.yellow);
zdotlo.SetLineWeight(3);
zdotlo.HideBubble();
#
 

Attachments

  • img2 - KMI 1min.JPG
    img2 - KMI 1min.JPG
    83.7 KB · Views: 47
Solution

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