Referencing a range of candles

Variety_Jones

New member
VIP
Hi All,

I'm trying perfect a breakout indicator/scanner based off the the Opening Range Breakout indicator. I want it to return true if (at least) one candle in the past 10 candles have touched a certain level (in this case the high of the opening range), and then the price dipped for a few candles, and then a candle closed over the ORH (opening range high).

I'm having a hard time writing the code without being too specific in the candles I'm referencing. Is there a way to reference 'at least one in the last 10 candles' rather than saying close[10] < ORH*.995 and low[5] < low[10] and low[1] > ORH etc....
 

tomsk

Well-known member
VIP
@Variety_Jones Something like the following should work.

def ORH = <some value previously defined>

Now to reference at least one candle in the last 10 that have closed above it, then the condition you need is

sum(close > ORH, 10) >= 1
 

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.
Top