It's weird.There were just pieces of missing code. The bubbles were already fixed in your code.
I have one additional request for this script which is having the choice of showing the bubbles for today only or show all.
Ruby:
# Opening_Range_Breakout Strategy with Risk and Target Lines
# Mobius
# This is V03.02.2017(B) Other versions start with V01.01.2001 Ported to TOS 06.2011
#hint: Opening Range Breakout is one of the original Floor Trader Strategies.\n Why it works: Overnight orders accumulate. Those orders being placed during the first 15 minutes of Regular Trading Hours combined with the typical high volume in the first 30 minutes of trading make this the most volatile trading period of the day. Regularly released reports during the first 30 minutes of trading add to the volatility and effect the days direction.\n Features of this study: The yellow dashed line is the Day Filter Line and is used to determin the trend direction for the day. The dominant time spent above or below this line during the Opening Range Period typically determines the days trend. Green points indicate a close at EOD above the yellow line. Red Points a close below the yellow line. Yellow points a neutral or balanced day, close Between the Opening Range Extremes and often very near the Day Filter Line. The Opening Range is plotted with a green and red dashed line. Trades can be taken when there is an open outside these range lines. Up to 10 Targets are generated using Average True Range to plot target lines. When price crosses the first target line part of the trade should be taken as Risk Off profit and a stop should be placed at the entry point ensuring a profitable trade. If price crosses further targets stops should be moved to the preceeding target until stopped or your profit target is met. Initial Risk Stops are an open below the bar's low prior to entry or the Risk Lines plotted below the Opening range Lines. When price tests the opening range lines from below for the upper line or above for the lower lines trades can be taken with a first target to the yellow line from either direction and a Risk Stop line outside the opening range at the First Target lines or a close outside the Opening Range Lines. \n FYI the color of Probable close direction points are statistically accurate between 60% and 70% of the time. Trading against the direction of the ORB's Day Filtered Direction should be considered counter trend trades.\n As of 01.03.2017 You have just under a 52% probability that a DAILY bar will close green. So a 60% to 70% probability is a nice edge.
# (B)Deletions / Additions: Deleted - Globex High / Low, Globex Volume and Averages.
# Additions: Added 5 more target lines for a total of 10 on each side of the Opening Range.
#20230601 Sleepyz - Added ONExpansion option
declare hide_on_daily;
declare once_per_bar;
input onexpansion_ORB = no;
input ORHL_Begin = 0930;
input ORHL_Start = 0935;
input EndOfFirstBar = 0935.0; #hint OrMeanE: End Mean period. Usually End of first bar.
input ORB_HL_Begin = 0930.0; #hint OrBegin: Beginning for Period of Opening Range Breakout.
input ORB_HL_Start = 1030.0; #hint OrEnd: End of Period of Opening Range Breakout.
input CloudOn_ORB = yes; #hint CloudOn: Clouds Opening Range.
input AlertOn = yes; #hint AlertOn: Alerts on cross of Opening Range.
input nAtr = 4; #hint nATR: Lenght for the ATR Risk and Target Lines.
input AtrTargetMult = 2.0; #hint ATRmult: Multiplier for the ATR calculations.
input bubble_ORB = yes;
input bubblemover_ORB = 0;
input ShowTodayOnly_ORB = { default "No","Yes"};
input MARKETOpen_ORB = 0930.0; #hint OrMeanS: Begin Mean Period. Usually Market Open EST.
###########
def rthrs = SecondsFromTime(0930) >= 0 and SecondsFromTime(1630) < 0;
###########
def h = high;
def l = low;
def c = close;
def s_orb = ShowTodayOnly_orb;
def today_ORB = if s_ORB == 0 or GetDay() == GetLastDay() and SecondsFromTime(MARKETOpen_ORB) >= 0 then 1 else 0;
def today = if s_orb == 0 or GetDay() == GetLastDay() and SecondsFromTime(ORHL_Begin) >= 0 then 1 else 0;
def na = double.nan;
def na_ORB = Double.NaN;
def ORActive = if SecondsTillTime(EndOfFirstBar) > 0 and SecondsFromTime(MARKETOpen_ORB) >= 0 then 1 else 0;
def ORActiveHL = if SecondsTillTime(ORHL_Start) > 0 and
SecondsFromTime(ORHL_Begin) >= 0 then 1 else 0;
def ORHigh = if ORHigh[1] == 0 or ORActiveHL[1] == 0 and ORActiveHL == 1 then h else if ORActiveHL and h > ORHigh[1] then h else ORHigh[1];
def ORLow = if ORLow[1] == 0 or ORActiveHL[1] == 0 and ORActiveHL == 1 then l else if ORActiveHL and l < ORLow[1] then l else ORLow[1];
def ORWidth = ORHigh - ORLow;
def ORHA = if ORActiveHL or today_ORB < 1 then na_ORB else ORHigh;
def ORLA = if ORActiveHL or today_ORB < 1 then na_ORB else ORLow;
def O = ORHA - Round(((ORHA - ORLA) / 2) / TickSize(), 0) * TickSize();
def ORActive2 = if SecondsTillTime(ORB_HL_Start) > 0 and SecondsFromTime(ORB_HL_Begin) >= 0 then 1 else 0;
def ORHigh2 = if ORHigh2[1] == 0 or ORActive2[1] == 0 and ORActive2 == 1 then h else if ORActive2 and h > ORHigh2[1] then h else ORHigh2[1];
def ORLow2 = if ORLow2[1] == 0 or ORActive2[1] == 0 and ORActive2 == 1 then l else if ORActive2 and l < ORLow2[1] then l else ORLow2[1];
def ORWidth2 = ORHigh2 - ORLow2;
def TimeLine = if SecondsTillTime(ORB_HL_Start) == 0 then 1 else 0;
def ORmeanBar = if !ORActive and ORActive[1] then BarNumber() else ORmeanBar[1];
def ORendBar = if !ORActive2 and ORActive2[1]
then BarNumber() else ORendBar[1];
def ORL = If (O == 0 , na, O);
def ORH2 = if ORActive2 or today < 1 then na else ORHigh2;
plot ORB_BAL = if rthrs and !ORActive2 and onexpansion_ORB and !ORActive[2] and !IsNaN(close) then Double.NaN else if onexpansion_ORB and BarNumber() >= HighestAll(ORmeanBar) then HighestAll(if IsNaN(c[-1]) then ORL[1] else Double.NaN) else if !onexpansion_ORB and rthrs then ORL else Double.NaN;
ORB_BAL.SetDefaultColor(Color.MAGENTA);
ORB_BAL.SetPaintingStrategy(PaintingStrategy.DASHES);
ORB_BAL.SetLineWeight(1);
ORB_BAL.HideTitle();
plot ORB_H = if rthrs and !ORActive2 and onexpansion_ORB and !ORActive[2] and !IsNaN(close) then Double.NaN else if !ShowTodayOnly_orb and !oractive2 and rthrs then ORH2[1] else if onexpansion_ORB and BarNumber() >= HighestAll(ORendBar) then HighestAll(if IsNaN(c[-1]) then ORH2[1] else Double.NaN) else if !onexpansion_ORB and rthrs then ORH2 else Double.NaN;
ORB_H.SetDefaultColor(Color.GREEN);
ORB_H.SetPaintingStrategy(PaintingStrategy.DASHES);
ORB_H.SetLineWeight(2);
ORB_H.HideTitle();
def ORL2 = if ORActive2 or today_ORB < 1 then na_ORB else ORLow2;
plot ORB_L = if rthrs and !ORActive2 and onexpansion_ORB and !ORActive[2] and !IsNaN(close) then Double.NaN else if !ShowTodayOnly_orb and !oractive2 and rthrs then ORL2[1] else if onexpansion_ORB and BarNumber() >= HighestAll(ORendBar) then HighestAll(if IsNaN(c[-1]) then ORL2[1] else Double.NaN) else if !onexpansion_ORB and rthrs then ORL2 else Double.NaN;
ORB_L.SetDefaultColor(Color.RED);
ORB_L.SetPaintingStrategy(PaintingStrategy.DASHES);
ORB_L.SetLineWeight(2);
ORB_L.HideTitle();
def RelDay = (ORL - ORL2) / (ORH2 - ORL2);
def dColor = if RelDay > .5 then 5 else if RelDay < .5 then 6 else 4;
def pos = (ORH2 - ORL2) / 10;
def mover_ORB = bubble_ORB and onexpansion_ORB and IsNaN(close[bubblemover_ORB]) and !IsNaN(close[bubblemover_ORB + 1]);
AddCloud(if CloudOn_ORB and !ORActive2 and !onexpansion_ORB and !ORActive[2] and rthrs == yes then ORL else Double.NaN, ORL2, Color.LIGHT_RED, Color.LIGHT_RED);
AddCloud(if CloudOn_ORB and !ORActive2 and !onexpansion_ORB and !ORActive[2] and rthrs == yes then ORL else Double.NaN, ORH2, Color.GREEN, Color.GREEN);
AddChartBubble(bubble_ORB and !ORActive2 and !onexpansion_ORB and !ORActive[2] and IsNaN(ORB_H[bubblemover_ORB - 1]) and !IsNaN(ORB_H[bubblemover_ORB]), ORB_H[bubblemover_ORB], "IB_H", ORB_H.TakeValueColor());
AddChartBubble(bubble_ORB and !ORActive2 and !onexpansion_ORB and !ORActive[2] and IsNaN(ORB_L[bubblemover_ORB - 1]) and !IsNaN(ORB_L[bubblemover_ORB]), ORB_L[bubblemover_ORB], "IB_L", ORB_L.TakeValueColor());
AddChartBubble(bubble_ORB and !ORActive2 and !onexpansion_ORB and !ORActive[2] and IsNaN(ORB_BAL[bubblemover_ORB - 1]) and !IsNaN(ORB_BAL[bubblemover_ORB]), ORB_BAL[bubblemover_ORB], "BAL", ORB_BAL.TakeValueColor());
#
Attachments
Last edited by a moderator: