Candle Range Breakout

johnwood34

New member
VIP
So...I'm currently backtesting candle range theory. Let's say my current candle range is a bullish candle. I mark the high and low of it. If that range is broken buy another bullish candle, I have to move my lines up to frame the high and low it. (My new range) If it had been broken by a bearish candle, I'd then have moved my lines down to frame that candle. Well...I'm monitoring five time frames, so constantly having to move my lines on each chart can be a tedious task. It's not as often on the high timeframes but on the lower ones, while price action is moving much quicker, this can be daunting. Is there an indicator available that would automatically map those lines out for me? Not a previous candle high and low. One that only maps out those tops and bottoms of the candle that closes out side of that range, creating a new one? Ive included a pic for reference. Candle underlined is the current range. Thanks in advance...
 

Attachments

  • Range.png
    Range.png
    481.9 KB · Views: 42
Solution
So...I'm currently backtesting candle range theory. Let's say my current candle range is a bullish candle. I mark the high and low of it. If that range is broken buy another bullish candle, I have to move my lines up to frame the high and low it. (My new range) If it had been broken by a bearish candle, I'd then have moved my lines down to frame that candle. Well...I'm monitoring five time frames, so constantly having to move my lines on each chart can be a tedious task. It's not as often on the high timeframes but on the lower ones, while price action is moving much quicker, this can be daunting. Is there an indicator available that would automatically map those lines out for me? Not a previous candle high and low. One that only...
So...I'm currently backtesting candle range theory. Let's say my current candle range is a bullish candle. I mark the high and low of it. If that range is broken buy another bullish candle, I have to move my lines up to frame the high and low it. (My new range) If it had been broken by a bearish candle, I'd then have moved my lines down to frame that candle. Well...I'm monitoring five time frames, so constantly having to move my lines on each chart can be a tedious task. It's not as often on the high timeframes but on the lower ones, while price action is moving much quicker, this can be daunting. Is there an indicator available that would automatically map those lines out for me? Not a previous candle high and low. One that only maps out those tops and bottoms of the candle that closes out side of that range, creating a new one? Ive included a pic for reference. Candle underlined is the current range. Thanks in advance...

here is something to experiment with
it might be what you want
if a green candle closes above the previous high line, then a new range is started.
if a red candle closes below the previous low line, then a new range is started.

Code:
# candle_range_breakout

#https://usethinkscript.com/threads/looking-for-an-indicator.20817/
#Looking for an indicator

#if candle is bullish,
#mark the high and low of it.
#..If that range is broken by another bullish candle, (close)
#...move my lines up to frame the high and low it.
#If it had been broken by a bearish candle, move lines down to frame that candle.

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

def o = open;
def h = high;
def l = low;
def c = close;

def grn = c > o;
def red = c < o;

def hi;
def lo;
if bn == 1 or isnan(close) then {
   hi = 0;
   lo = 0;
} else if grn and c > hi[1] then {
   hi = h;
   lo = l;
} else if red and c < lo[1] then {
   hi = h;
   lo = l;
} else {
   hi = hi[1];
   lo = lo[1];
}


plot z1 = if hi > 0 then hi else na;
plot z2 = if lo > 0 then lo else na;
z1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
z2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
z1.SetDefaultColor(Color.magenta);
z2.SetDefaultColor(Color.magenta);
#
 

Attachments

  • img1.JPG
    img1.JPG
    58.3 KB · Views: 51
Solution

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

here is something to experiment with
it might be what you want
if a green candle closes above the previous high line, then a new range is started.
if a red candle closes below the previous low line, then a new range is started.

Code:
# candle_range_breakout

#https://usethinkscript.com/threads/looking-for-an-indicator.20817/
#Looking for an indicator

#if candle is bullish,
#mark the high and low of it.
#..If that range is broken by another bullish candle, (close)
#...move my lines up to frame the high and low it.
#If it had been broken by a bearish candle, move lines down to frame that candle.

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

def o = open;
def h = high;
def l = low;
def c = close;

def grn = c > o;
def red = c < o;

def hi;
def lo;
if bn == 1 or isnan(close) then {
   hi = 0;
   lo = 0;
} else if grn and c > hi[1] then {
   hi = h;
   lo = l;
} else if red and c < lo[1] then {
   hi = h;
   lo = l;
} else {
   hi = hi[1];
   lo = lo[1];
}


plot z1 = if hi > 0 then hi else na;
plot z2 = if lo > 0 then lo else na;
z1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
z2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
z1.SetDefaultColor(Color.magenta);
z2.SetDefaultColor(Color.magenta);
#
I can work with that! Thank you so much!!!
 
here is something to experiment with
it might be what you want
if a green candle closes above the previous high line, then a new range is started.
if a red candle closes below the previous low line, then a new range is started.

Code:
# candle_range_breakout

#https://usethinkscript.com/threads/looking-for-an-indicator.20817/
#Looking for an indicator

#if candle is bullish,
#mark the high and low of it.
#..If that range is broken by another bullish candle, (close)
#...move my lines up to frame the high and low it.
#If it had been broken by a bearish candle, move lines down to frame that candle.

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

def o = open;
def h = high;
def l = low;
def c = close;

def grn = c > o;
def red = c < o;

def hi;
def lo;
if bn == 1 or isnan(close) then {
   hi = 0;
   lo = 0;
} else if grn and c > hi[1] then {
   hi = h;
   lo = l;
} else if red and c < lo[1] then {
   hi = h;
   lo = l;
} else {
   hi = hi[1];
   lo = lo[1];
}


plot z1 = if hi > 0 then hi else na;
plot z2 = if lo > 0 then lo else na;
z1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
z2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
z1.SetDefaultColor(Color.magenta);
z2.SetDefaultColor(Color.magenta);
#
Hey! Just wanna thank you again for the script and quick response!! I ABSOLUTELY LOVE IT!!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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