Opening Range Breakout Indicator with Fibs

ken_trades

New member
Hi guys, i have a ORB indicator with Fibs, but i need help with adding chart labels on the levels. I tried myself but it showed me this many chart bubbles
JXQ0aL8.png


Code:
# Automatic Opening Range and Fibonacci Levels
def na=double.nan;

# Define time that OR begins (in hhmm format,
# 0930 is the default):
input ORBegin = 0930;

# Define time that OR is finished (in hhmm format,
# 10:00 is the default):
input OREnd = 1000;

# Input first and second fib extension levels
# (default 1.382, 1.621):
Input FibExt1=1.382;
Input FibExt2=1.621;
Input FibExt3=2.0;
Input FibExt4=2.618;

# Show Today only? (Default Yes)
input ShowTodayOnly={"No", default "Yes"};
def s=ShowTodayOnly;

# Show Second fib extension? (Default No)
input ShowFibExt2={default "No", "Yes"};
def sf2=ShowFibExt2;

# Create logic for OR definition:
def ORActive = if secondstilltime(OREnd)>0 AND secondsfromtime(ORBegin)>=0 then 1 else 0;

# Create logic to paint only current day post-open:
def today=if s==0 OR getday()==getlastday() AND secondsfromtime(ORBegin)>=0 then 1 else 0;

# Track OR High:
rec ORHigh = if ORHigh[1]==0 or ORActive[1]==0 AND ORActive==1 then high else if ORActive AND high>ORHigh[1] then high else ORHigh[1];

# Track OR Low:
rec ORLow = if ORLow[1]==0 or ORActive[1]==0 AND ORActive==1 then low else if ORActive AND low<ORLow[1] then low else ORLow[1];

# Calculate OR width:
def ORWidth = ORHigh - ORLow;

# Calculate fib levels:
def fib_mid = (ORHigh+ORLow)/2;
def fib_ext_up1 = ORHigh + ORWidth*(FibExt1 - 1);
def  fib_ext_down1 = ORLow - ORWidth*(FibExt1 - 1);
def fib_ext_up2= ORHigh + ORWidth*(FibExt2 - 1);
def fib_ext_down2 = ORLow - ORWidth*(FibExt2 - 1);
def fib_ext_up3 = ORHigh + ORWidth*(FibExt3 - 1);
def fib_ext_down3 = ORLow - ORWidth*(FibExt3 - 1);
def fib_ext_up4= ORHigh + ORWidth*(FibExt4 - 1);
def fib_ext_down4 = ORLow - ORWidth*(FibExt4 - 1);

# Define all the plots:
plot ORH=if ORActive OR today<1 then na else ORHigh;
plot ORL=if ORActive OR today<1 then na else ORLow;
plot FibMid=if ORActive OR today<1 then na else fib_mid;
plot FibExtUp1=if ORActive OR today<1 then na else fib_ext_up1;
plot FibExtDown1=if ORActive OR today<1 then na else fib_ext_down1;
plot lot FibExtUp2=if ORActive OR today<1 OR sf2<1 then na else fib_ext_up2;
plot FibExtDown2=if ORActive OR today<1 OR sf2<1 then na else fib_ext_down2;
plot FibExtUp3=if ORActive OR today<1 then na else fib_ext_up3;
plot FibExtDown3=if ORActive OR today<1 then na else fib_ext_down3;
plot FibExtUp4=if ORActive OR today<1 OR sf2<1 then na else fib_ext_up4;
plot FibExtDown4=if ORActive OR today<1 OR sf2<1 then na else fib_ext_down4;

# Formatting:
ORH.setdefaultcolor(color.green);
ORH.setStyle(curve.Long_DASH);
ORH.setlineweight(3);
ORL.setdefaultcolor(color.red);
ORL.setStyle(curve.Long_DASH);
ORL.setlineweight(3);
AddChartBubble(ORHigh, ORH, "ORH", color.green, yes);

FibMid.setdefaultcolor(color.gray);
FibMid.setStyle(curve.SHORT_DASH);
FibMid.setlineweight(3);
FibExtUp1.setdefaultcolor(color.green);
FibExtUp1.setStyle(curve.SHORT_DASH);
FibExtUp1.setlineweight(2);
FibExtDown1.setdefaultcolor(color.red);
FibExtDown1.setStyle(curve.SHORT_DASH);
FibExtDown1.setlineweight(2);
FibExtUp2.setdefaultcolor(color.green);
FibExtUp2.setStyle(curve.SHORT_DASH);
FibExtUp2.setlineweight(1);
FibExtDown2.setdefaultcolor(color.red);
FibExtDown2.setStyle(curve.SHORT_DASH);
FibExtDown2.setlineweight(1);
FibExtUp3.setdefaultcolor(color.green);
FibExtUp3.setStyle(curve.SHORT_DASH);
FibExtUp3.setlineweight(2);
FibExtDown3.setdefaultcolor(color.red);
FibExtDown3.setStyle(curve.SHORT_DASH);
FibExtDown3.setlineweight(2);
FibExtUp4.setdefaultcolor(color.green);
FibExtUp4.setStyle(curve.SHORT_DASH);
FibExtUp4.setlineweight(1);
FibExtDown4.setdefaultcolor(color.red);
FibExtDown4.setStyle(curve.SHORT_DASH);
FibExtDown4.setlineweight(1);
 
Last edited by a moderator:
Solution
@ken_trades Try something like this, and make sure you have Time Axis, Expansion area configured for at-least 5 bars.

Ruby:
AddChartBubble(IsNaN(close), ORHigh[1], Concat("ORH ", ORHigh[1]), Color.GREEN, yes);

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