BubbleMover Code Snippet for ThinkOrSwim

JG5Jlo7.jpg



Hello, is it possible to move these numbered tags(chart bubbles)higher or lower so they dont cover the candles? They pop up during accumulation of the candle and obsure my view of the candle unless i zoom way in and its pretty inconvenient. ive tried to change the chart bubble code based off of other indicators but i cant seem to get it working. Any assistance would be greatly appreciated. Thanks for your time and effort.

These numbered tags(chart bubbles) count legs for the "2 legged pullback" strategy i use.

--------------------------------------------------------------------------------------------------------------------------------------



Code:
def trend = {default init, neutral, up, down};

def marginBelow = 5 * TickSize();
def marginAbove = 2 * TickSize();



switch (trend[1]) {
case init:
    trend = trend.neutral;
case neutral:
    if (high > high[1]) {
        trend = trend.up;
    } else if (low < low[1]) {
        trend = trend.down;
    } else {
        trend = trend.neutral;
    }
case up:
    if (low < low[1]) {
        trend = trend.down;
    } else {
        trend = trend[1];
    }
case down:
    if (high > high[1]) {
        trend = trend.up;
    } else {
        trend = trend[1];
    }
}


def currentHigh;
if trend == trend.up  {
    if high > currentHigh[1] {
        currentHigh = high;
    } else {
        currentHigh = currentHigh[1];
    }
} else {
    currentHigh = -1;
}


def currentLow;
if trend == trend.down {
    if  low < currentLow[1] {
        currentLow = low;
    } else {
        currentLow = currentLow[1];
    }
} else {
    currentLow = 999999;
}

def trueLow = Min(currentLow[1], low);
def trueHi = Max(currentHigh[1], high);


plot upArrow;
def countLegUp;
def previousLow;
def pivotLowHi;
if trend == trend.up && trend[1] == trend.down {
    if  previousLow[1] > trueLow {
        countLegUp = 1;
    } else {
        countLegUp = countLegUp[1] + 1;
    }
    previousLow = trueLow;
    upArrow = low - (2 * TickSize());
    pivotLowHi = high[1];
} else {
    previousLow = previousLow[1];
    countLegUp = countLegUp[1];
    upArrow = Double.NaN;
    pivotLowHi = pivotLowHi[1];
}



plot downArrow;
def countLegDown;
def previousHigh;
def pivotHiLow;
if trend == trend.down && trend[1] == trend.up {
    if previousHigh[1] < Max(currentHigh[1], high) {
        countLegDown = 1;
    } else {
        countLegDown = countLegDown[1] + 1;
    }
    previousHigh = Max(currentHigh[1], high);
    downArrow = high + (2 * TickSize());
    pivotHiLow = low[1];

} else {
    previousHigh = previousHigh[1];
    countLegDown = countLegDown[1];
    pivotHiLow = pivotHiLow[1];
    downArrow = Double.NaN;
}


def failedShort;
if pivotHiLow - trueLow <= 1
{
    failedShort = 1;
} else {
    failedShort = 0;
}

def failedLong;
if trueHi - pivotLowHi <= 1
{
    failedLong = 1;
} else {
    failedLong = 0;
}


AddChartBubble(downArrow, high + marginAbove, countLegDown,  if countLegDown[1] > 1 && failedLong then Color.MAGENTA else if countLegUp > 1 then Color.DARK_RED else if countLegDown > 1 then Color.LIGHT_RED else Color.GRAY);


AddChartBubble(upArrow, low - marginBelow, countLegUp, if countLegUp[1] > 1 && failedShort then Color.cyan else if countLegDown > 1 then Color.DARK_GREEN else if countLegUp > 1 then Color.LIGHT_GREEN else Color.GRAY);

#uncomment below if you want to add arrows
#upArrow.SetDefaultColor(Color.GREEN);
#upArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
#downArrow.SetDefaultColor(Color.RED);
#downArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
 
Hello, is it possible to move these numbered tags(chart bubbles)higher or lower so they dont cover the candles? They pop up during accumulation of the candle and obsure my view of the candle unless i zoom way in and its pretty inconvenient. ive tried to change the chart bubble code based off of other indicators but i cant seem to get it working. Any assistance would be greatly appreciated. Thanks for your time and effort.

These numbered tags(chart bubbles) count legs for the "2 legged pullback" strategy i use.

--------------------------------------------------------------------------------------------------------------------------------------



Code:
def trend = {default init, neutral, up, down};

def marginBelow = 5 * TickSize();
def marginAbove = 2 * TickSize();



switch (trend[1]) {
case init:
    trend = trend.neutral;
case neutral:
    if (high > high[1]) {
        trend = trend.up;
    } else if (low < low[1]) {
        trend = trend.down;
    } else {
        trend = trend.neutral;
    }
case up:
    if (low < low[1]) {
        trend = trend.down;
    } else {
        trend = trend[1];
    }
case down:
    if (high > high[1]) {
        trend = trend.up;
    } else {
        trend = trend[1];
    }
}


def currentHigh;
if trend == trend.up  {
    if high > currentHigh[1] {
        currentHigh = high;
    } else {
        currentHigh = currentHigh[1];
    }
} else {
    currentHigh = -1;
}


def currentLow;
if trend == trend.down {
    if  low < currentLow[1] {
        currentLow = low;
    } else {
        currentLow = currentLow[1];
    }
} else {
    currentLow = 999999;
}

def trueLow = Min(currentLow[1], low);
def trueHi = Max(currentHigh[1], high);


plot upArrow;
def countLegUp;
def previousLow;
def pivotLowHi;
if trend == trend.up && trend[1] == trend.down {
    if  previousLow[1] > trueLow {
        countLegUp = 1;
    } else {
        countLegUp = countLegUp[1] + 1;
    }
    previousLow = trueLow;
    upArrow = low - (2 * TickSize());
    pivotLowHi = high[1];
} else {
    previousLow = previousLow[1];
    countLegUp = countLegUp[1];
    upArrow = Double.NaN;
    pivotLowHi = pivotLowHi[1];
}



plot downArrow;
def countLegDown;
def previousHigh;
def pivotHiLow;
if trend == trend.down && trend[1] == trend.up {
    if previousHigh[1] < Max(currentHigh[1], high) {
        countLegDown = 1;
    } else {
        countLegDown = countLegDown[1] + 1;
    }
    previousHigh = Max(currentHigh[1], high);
    downArrow = high + (2 * TickSize());
    pivotHiLow = low[1];

} else {
    previousHigh = previousHigh[1];
    countLegDown = countLegDown[1];
    pivotHiLow = pivotHiLow[1];
    downArrow = Double.NaN;
}


def failedShort;
if pivotHiLow - trueLow <= 1
{
    failedShort = 1;
} else {
    failedShort = 0;
}

def failedLong;
if trueHi - pivotLowHi <= 1
{
    failedLong = 1;
} else {
    failedLong = 0;
}


AddChartBubble(downArrow, high + marginAbove, countLegDown,  if countLegDown[1] > 1 && failedLong then Color.MAGENTA else if countLegUp > 1 then Color.DARK_RED else if countLegDown > 1 then Color.LIGHT_RED else Color.GRAY);


AddChartBubble(upArrow, low - marginBelow, countLegUp, if countLegUp[1] > 1 && failedShort then Color.cyan else if countLegDown > 1 then Color.DARK_GREEN else if countLegUp > 1 then Color.LIGHT_GREEN else Color.GRAY);

#uncomment below if you want to add arrows
#upArrow.SetDefaultColor(Color.GREEN);
#upArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
#downArrow.SetDefaultColor(Color.RED);
#downArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

your bubble functions are missing the 5th parameter.
yes is point down. no is point up.
add , no to the low bubble.
i would simplify it, by using the same vertical offset for bubble location. ( marginBelow )

Code:
AddChartBubble(downArrow, high + marginAbove, countLegDown,  if countLegDown[1] > 1 && failedLong then Color.MAGENTA else if countLegUp > 1 then Color.DARK_RED else if countLegDown > 1 then Color.LIGHT_RED else Color.GRAY, yes);

AddChartBubble(upArrow, low - marginBelow, countLegUp, if countLegUp[1] > 1 && failedShort then Color.cyan else if countLegDown > 1 then Color.DARK_GREEN else if countLegUp > 1 then Color.LIGHT_GREEN else Color.GRAY, no);
]/code]
 
Looking for:

1. code to just show the previous candle open as a bubble?

2. Is there a way to just show the previous candle open no matter what time frame your chart is on?

3. Can someone help with an indicator to show a bubble of current candle open for scalping NQ?
 
Last edited by a moderator:
Looking for:

1. code to just show the previous candle open as a bubble?

2. Is there a way to just show the previous candle open no matter what time frame your chart is on?

3. Can someone help with an indicator to show a bubble of current candle open for scalping NQ?

This should do all 3 above

Screenshot-2023-01-31-105041.png
Code:
addchartBubble(isnan(close[-2]) and !isnan(close[1]), high, "O: " +  open, color.white);
 
Without your code, here is an example that has a bubblemover input that you can use to move the bubbles left/right.
Hey SleepyZ, I have tried every bubble mover snippet I can find, I cant seem to get it to work, I have limited coding skills, but most things I am able to figure out by watching Youtube, but this one has me stumped, every couple of months ill give it a shot, but always back to square 1, last resort = ask for help.

If you/anyone could help me insert a snippet of bubble code mover in the below script I would be very greatful! P.S. I have a bubble mover code at the bottom and inputs at top


Code:
##

DECLARE UPPER;
input showbubbles = yes;
input bubblemover = 2;
INPUT AGG = AGgregationPeriod.DAY;
INPUT BUBBLES = NO;
INPUT LABELS = NO;
INPUT CLOSEWEIGHTTODAY = NO;
INPUT CLOSEWEIGHTYEST = yes;
INPUT CLOSEWEIGHTTWODAY = yes;
PLOT HI = HIGH(PERIOD = AGG);
PLOT LO = LOW(PERIOD = AGG);
PLOT YHI = HIGH(PERIOD = AGG)[1];
PLOT YLO = LOW(PERIOD = AGG)[1];
PLOT FIFTYPCT = if cloSEWEIGHTTODAY then (hi + lo + close(period = agg)) / 3 else (HI + LO) / 2;
PLOT YESTERDAYFTYPCT = if cloSEWEIGHTYEST then (yhi + ylo + close(period = agg)[1]) / 3 else (YHI + YLO) / 2;
DEF WHICHHI = IF YHI > YHI[1] THEN YHI ELSE YHI[1];
DEF WHICHLO = IF YLO < YLO[1] THEN YLO ELSE YLO[1];
DEF TODAY = if (GetDay() == GetLastDay()) or (GetlastDay() - 1 == getday()) then yes else no;
DEF BUBBLESPOT = if IsNaN(open[-1]) && !IsNaN(open) then (BarNumber() - 1) else DOUBLE.NAN;
PLOT FIFTYPCTTWODAY = if ClOSEWEIGHTTWODAY then (WHICHHI + WHICHLO + close(period = AGG)[1]) / 3 else (WHICHHI + WHICHLO) / 2;
plot PP  = PivotPoints().pp;
HI.SETLINEWeight(2);
LO.SETLINEWeight(2);
HI.SETDefaultColor(CREATECOlor(166,130,166));
LO.SETDefaultColor(CREATECOlor(166,130,166));
YLO.SETDefaultColor(CREATECOlor(146,120,146));
YHI.SETDefaultColor(CREATECOlor(146,120,146));
FIFTYPCT.setDefaultColor(Color.GRAY);
FIFTYPCT.setpaintingStrategy(paintingStrategy.DASHES);
YESTERDAYFTYPCT.setDefaultColor(Color.Dark_GRAY);
YESTERDAYFTYPCT.setpaintingStrategy(paintingStrategy.SQUARES);
FIFTYPCTTWODAY.setDefaultColor(Color.GRAY);
FIFTYPCTTWODAY.setpaintingStrategy(paintingStrategy.TRIANGLES);
ADDLABEL(LABELS, "HI/50/LO=" + HI + "/ " + FIFTYPCT +"/ " + LO, CREATECOlor(166,130,166));
ADDLABEL(LABELS, "2D 50%=" + FIFTYPCTTWODAY, COLOR.GRAY);
ADDLABEL(LABELS, "YEST=" + YHI + "/ " + YESTERDAYFTYPCT + "/ " + YLO, CREATECOlor(146,120,146));

#

ADDCHARTBUBBLE (BUBBLES AND TODAY AND BUBBLESPOT, HI,  "HI",CREATECOlor(166,130,166), YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, LO, "LO",CREATECOlor(166,130,166), NO);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, YHI, "YEST HI",CREATECOlor(146,120,146), if close > YHI then NO else YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, YLO, "YEST LO",CREATECOlor(146,120,146), if close > YLO then NO else YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, FIFTYPCT, "TODAY 50%", COLOR.GRAY, IF CLOSE > FIFTYPCT THEN NO ELSE YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, YESTERDAYFTYPCT, "1D 50%", COLOR.GRAY, IF CLOSE > YESTERDAYFTYPCT THEN NO ELSE YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, FIFTYPCTTWODAY, "2D 50%", COLOR.GRAY, IF CLOSE > FIFTYPCTTWODAY THEN NO ELSE YES);

#bubbles
input showbubble  = yes;

def bm  = bubblemover;
def bm1 = bm + 1;
 
Hey SleepyZ, I have tried every bubble mover snippet I can find, I cant seem to get it to work, I have limited coding skills, but most things I am able to figure out by watching Youtube, but this one has me stumped, every couple of months ill give it a shot, but always back to square 1, last resort = ask for help.

If you/anyone could help me insert a snippet of bubble code mover in the below script I would be very greatful! P.S. I have a bubble mover code at the bottom and inputs at top


Code:
##

DECLARE UPPER;
input showbubbles = yes;
input bubblemover = 2;
INPUT AGG = AGgregationPeriod.DAY;
INPUT BUBBLES = NO;
INPUT LABELS = NO;
INPUT CLOSEWEIGHTTODAY = NO;
INPUT CLOSEWEIGHTYEST = yes;
INPUT CLOSEWEIGHTTWODAY = yes;
PLOT HI = HIGH(PERIOD = AGG);
PLOT LO = LOW(PERIOD = AGG);
PLOT YHI = HIGH(PERIOD = AGG)[1];
PLOT YLO = LOW(PERIOD = AGG)[1];
PLOT FIFTYPCT = if cloSEWEIGHTTODAY then (hi + lo + close(period = agg)) / 3 else (HI + LO) / 2;
PLOT YESTERDAYFTYPCT = if cloSEWEIGHTYEST then (yhi + ylo + close(period = agg)[1]) / 3 else (YHI + YLO) / 2;
DEF WHICHHI = IF YHI > YHI[1] THEN YHI ELSE YHI[1];
DEF WHICHLO = IF YLO < YLO[1] THEN YLO ELSE YLO[1];
DEF TODAY = if (GetDay() == GetLastDay()) or (GetlastDay() - 1 == getday()) then yes else no;
DEF BUBBLESPOT = if IsNaN(open[-1]) && !IsNaN(open) then (BarNumber() - 1) else DOUBLE.NAN;
PLOT FIFTYPCTTWODAY = if ClOSEWEIGHTTWODAY then (WHICHHI + WHICHLO + close(period = AGG)[1]) / 3 else (WHICHHI + WHICHLO) / 2;
plot PP  = PivotPoints().pp;
HI.SETLINEWeight(2);
LO.SETLINEWeight(2);
HI.SETDefaultColor(CREATECOlor(166,130,166));
LO.SETDefaultColor(CREATECOlor(166,130,166));
YLO.SETDefaultColor(CREATECOlor(146,120,146));
YHI.SETDefaultColor(CREATECOlor(146,120,146));
FIFTYPCT.setDefaultColor(Color.GRAY);
FIFTYPCT.setpaintingStrategy(paintingStrategy.DASHES);
YESTERDAYFTYPCT.setDefaultColor(Color.Dark_GRAY);
YESTERDAYFTYPCT.setpaintingStrategy(paintingStrategy.SQUARES);
FIFTYPCTTWODAY.setDefaultColor(Color.GRAY);
FIFTYPCTTWODAY.setpaintingStrategy(paintingStrategy.TRIANGLES);
ADDLABEL(LABELS, "HI/50/LO=" + HI + "/ " + FIFTYPCT +"/ " + LO, CREATECOlor(166,130,166));
ADDLABEL(LABELS, "2D 50%=" + FIFTYPCTTWODAY, COLOR.GRAY);
ADDLABEL(LABELS, "YEST=" + YHI + "/ " + YESTERDAYFTYPCT + "/ " + YLO, CREATECOlor(146,120,146));

#

ADDCHARTBUBBLE (BUBBLES AND TODAY AND BUBBLESPOT, HI,  "HI",CREATECOlor(166,130,166), YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, LO, "LO",CREATECOlor(166,130,166), NO);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, YHI, "YEST HI",CREATECOlor(146,120,146), if close > YHI then NO else YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, YLO, "YEST LO",CREATECOlor(146,120,146), if close > YLO then NO else YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, FIFTYPCT, "TODAY 50%", COLOR.GRAY, IF CLOSE > FIFTYPCT THEN NO ELSE YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, YESTERDAYFTYPCT, "1D 50%", COLOR.GRAY, IF CLOSE > YESTERDAYFTYPCT THEN NO ELSE YES);
ADDCHARTBUBBLE(BUBBLES AND TODAY AND BUBBLESPOT, FIFTYPCTTWODAY, "2D 50%", COLOR.GRAY, IF CLOSE > FIFTYPCTTWODAY THEN NO ELSE YES);

#bubbles
input showbubble  = yes;

def bm  = bubblemover;
def bm1 = bm + 1;

you didn't explain
what, when, where
you want to see something on the chart.

where do you want the bubble to show up?


the BUBBLESPOT formula is a number or nan.
your bubbles are treating that variable like a true/false instead of comparing the value to something.

should be,
and BUBBLESPOT == barnumber()
or something like that.
 
you didn't explain
what, when, where
you want to see something on the chart.

where do you want the bubble to show up?


the BUBBLESPOT formula is a number or nan.
your bubbles are treating that variable like a true/false instead of comparing the value to something.

should be,
and BUBBLESPOT == barnumber()
or something like that.
Sorry, I specifically replied to Sleepyz's post because he had his bubbles being shifted to the right (horizontally). My bubbles in my code are basically on top of the candles and just prefer it to be more to the right, 10 bars or so.

Thanks for the advice man!
 
Sorry, I specifically replied to Sleepyz's post because he had his bubbles being shifted to the right (horizontally). My bubbles in my code are basically on top of the candles and just prefer it to be more to the right, 10 bars or so.

Thanks for the advice man!


If you are still needing help with the bubblemover code, the BOLD code should help.

Rich (BB code):
##

declare upper;

input showbubbles = yes;
input bubblemover = 8;

input AGG = AggregationPeriod.DAY;
input LABELS = NO;
input CLOSEWEIGHTTODAY = NO;
input CLOSEWEIGHTYEST = yes;
input CLOSEWEIGHTTWODAY = yes;
plot HI = high(PERIOD = AGG);
plot LO = low(PERIOD = AGG);
plot YHI = high(PERIOD = AGG)[1];
plot YLO = low(PERIOD = AGG)[1];
plot FIFTYPCT = if CLOSEWEIGHTTODAY then (HI + LO + close(period = AGG)) / 3 else (HI + LO) / 2;
plot YESTERDAYFTYPCT = if CLOSEWEIGHTYEST then (YHI + YLO + close(period = AGG)[1]) / 3 else (YHI + YLO) / 2;
def WHICHHI = if YHI > YHI[1] then YHI else YHI[1];
def WHICHLO = if YLO < YLO[1] then YLO else YLO[1];
def TODAY = if (GetDay() == GetLastDay()) or (GetLastDay() - 1 == GetDay()) then yes else no;

plot FIFTYPCTTWODAY = if CLOSEWEIGHTTWODAY then (WHICHHI + WHICHLO + close(period = AGG)[1]) / 3 else (WHICHHI + WHICHLO) / 2;
plot PP  = PivotPoints().pp;
HI.SetLineWeight(2);
LO.SetLineWeight(2);
HI.SetDefaultColor(CreateColor(166, 130, 166));
LO.SetDefaultColor(CreateColor(166, 130, 166));
YLO.SetDefaultColor(CreateColor(146, 120, 146));
YHI.SetDefaultColor(CreateColor(146, 120, 146));
FIFTYPCT.SetDefaultColor(Color.GRAY);
FIFTYPCT.SetPaintingStrategy(PaintingStrategy.DASHES);
YESTERDAYFTYPCT.SetDefaultColor(Color.DARK_GRAY);
YESTERDAYFTYPCT.SetPaintingStrategy(PaintingStrategy.SQUARES);
FIFTYPCTTWODAY.SetDefaultColor(Color.GRAY);
FIFTYPCTTWODAY.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
AddLabel(LABELS, "HI/50/LO=" + HI + "/ " + FIFTYPCT + "/ " + LO, CreateColor(166, 130, 166));
AddLabel(LABELS, "2D 50%=" + FIFTYPCTTWODAY, Color.GRAY);
AddLabel(LABELS, "YEST=" + YHI + "/ " + YESTERDAYFTYPCT + "/ " + YLO, CreateColor(146, 120, 146));

#

#bubbles
def bm  = bubblemover;
def bm1 = bm + 1;
def BUBBLESPOT = showbubbles and IsNaN(close[bm]) && !IsNaN(close[bm1]);

AddChartBubble (BUBBLESPOT, HI, "HI", CreateColor(166, 130, 166), yes);
AddChartBubble(BUBBLESPOT, LO, "LO", CreateColor(166, 130, 166), no);
AddChartBubble(BUBBLESPOT, YHI, "YEST HI", CreateColor(146, 120, 146), if close > YHI then no else yes);
AddChartBubble(BUBBLESPOT, YLO, "YEST LO", CreateColor(146, 120, 146), if close > YLO then no else yes);
AddChartBubble(BUBBLESPOT, FIFTYPCT, "TODAY 50%", Color.GRAY, if close > FIFTYPCT then no else yes);
AddChartBubble(BUBBLESPOT, YESTERDAYFTYPCT, "1D 50%", Color.GRAY, if close > YESTERDAYFTYPCT then no else yes);
AddChartBubble(BUBBLESPOT, FIFTYPCTTWODAY, "2D 50%", Color.GRAY, if close > FIFTYPCTTWODAY then no else yes);
 
If you are still needing help with the bubblemover code, the BOLD code should help.
2023-05-31_12h09_43.png
Hey man, no rush on this, but I have been trying to figure out how to move any instance of a bubble within an ORB script, but I am not having any luck. Even Chatgpt's 22 attempts didnt work :LOL: . If you look at the screenshot, I would like all of those instances of a bubble, moved to the right 8 bars or so

Here is the original code:

Code:
declare Hide_On_Daily;
declare Once_per_bar;


input OrMeanS  = 0930.0; #hint OrMeanS: Begin Mean Period. Usually Market Open EST.
input OrMeanE  = 0935.0; #hint OrMeanE: End Mean period. Usually End of first bar.
input OrBegin  = 0930.0; #hint OrBegin: Beginning for Period of Opening Range Breakout.
input OrEnd    = 1000.0; #hint OrEnd: End of Period of Opening Range Breakout.
input CloudOn  = no;     #hint CloudOn: Clouds Opening Range.
input AlertOn  = yes;    #hint AlertOn: Alerts on cross of Opening Range.
input ShowTodayOnly = {"No", default "Yes"}; 
input nAtr = 4;          #hint nATR: Lenght for the ATR Risk and Target Lines.
input AtrTargetMult = 2.0; #hint ATRmult: Multiplier for the ATR calculations.

  def h = high;
  def l = low;
  def c = close;
  def bar = barNumber();
  def s = ShowTodayOnly;
  def ORActive = if secondsTillTime(OrMeanE) > 0 and
                    secondsFromTime(OrMeanS) >= 0
                 then 1
                 else 0;
  def today = if s == 0
              or getDay() == getLastDay() and
                 secondsFromTime(OrMeanS) >= 0
              then 1
              else 0;
  def ORHigh = if ORHigh[1] == 0
               or ORActive[1] == 0 and
                  ORActive == 1
               then h
               else if ORActive and
                       h > ORHigh[1]
               then h
               else ORHigh[1];
  def ORLow = if ORLow[1] == 0
              or ORActive[1] == 0 and
                 ORActive == 1
              then l
              else if ORActive and
                      l < ORLow[1]
              then l
              else ORLow[1];
  def ORWidth = ORHigh - ORLow;
  def na = double.nan;
  def ORHA = if ORActive
             or today < 1
             then na
             else ORHigh;
  def ORLA = if ORActive
             or today < 1
             then na
             else ORLow;
  def O = ORHA - Round(((ORHA - ORLA) / 2) / TickSize(), 0) * TickSize();
  def ORActive2 = if secondsTillTime(OREnd) > 0 and
                     secondsFromTime(ORBegin) >= 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(OREnd) == 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);
plot ORLext = if barNumber() >= highestAll(ORmeanBar)
              then HighestAll(if isNaN(c[-1])
                              then ORL[1]
                              else double.nan)
              else double.nan;
     ORLext.SetDefaultColor(color.Yellow);
     ORLext.SetStyle(curve.Long_DASH);
     ORLext.SetLineWeight(3);
     ORLext.HideTitle();
  def ORH2 = if ORActive2
             or today < 1
             then na
             else ORHigh2;
plot ORH2ext = if barNumber() >= highestAll(ORendBar)
               then HighestAll(if isNaN(c[-1])
                               then ORH2[1]
                               else double.nan)
               else double.nan;
     ORH2ext.SetDefaultColor(color.Green);
     ORH2ext.SetStyle(curve.Long_DASH);
     ORH2ext.SetLineWeight(3);
     ORH2ext.HideTitle();
  def ORL2 = if ORActive2
               or today < 1
             then na
             else ORLow2;
plot ORL2ext = if barNumber() >= highestAll(ORendBar)
               then HighestAll(if isNaN(c[-1])
                               then ORL2[1]
                               else double.nan)
               else double.nan;
     ORL2ext.SetDefaultColor(color.Red);
     ORL2ext.SetStyle(curve.Long_DASH);
     ORL2ext.SetLineWeight(3);
     ORL2ext.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;
plot d1 = if (TimeLine , ORH2, na);
plot d2 = if (TimeLine , ORH2 - ( pos * 2), na);
plot d3 = if (TimeLine , ORH2 - ( pos * 3), na);
plot d4 = if (TimeLine , ORH2 - ( pos * 4), na);
plot d5 = if (TimeLine , ORH2 - ( pos * 5), na);
plot d6 = if (TimeLine , ORH2 - ( pos * 6), na);
plot d7 = if (TimeLine , ORH2 - ( pos * 7), na);
plot d8 = if (TimeLine , ORH2 - ( pos * 8), na);
plot d9 = if (TimeLine , ORH2 - ( pos * 9), na);
plot d10 = if (TimeLine ,(ORL2), na);
     d1.SetPaintingStrategy(PaintingStrategy.POINTS);
     d2.SetPaintingStrategy(PaintingStrategy.POINTS);
     d3.SetPaintingStrategy(PaintingStrategy.POINTS);
     d4.SetPaintingStrategy(PaintingStrategy.POINTS);
     d5.SetPaintingStrategy(PaintingStrategy.POINTS);
     d6.SetPaintingStrategy(PaintingStrategy.POINTS);
     d7.SetPaintingStrategy(PaintingStrategy.POINTS);
     d8.SetPaintingStrategy(PaintingStrategy.POINTS);
     d9.SetPaintingStrategy(PaintingStrategy.POINTS);
    d10.SetPaintingStrategy(PaintingStrategy.POINTS);
     d1.AssignValueColor(GetColor(Dcolor));
     d2.AssignValueColor(GetColor(Dcolor));
     d3.AssignValueColor(GetColor(Dcolor));
     d4.AssignValueColor(GetColor(Dcolor));
     d5.AssignValueColor(GetColor(Dcolor));
     d6.AssignValueColor(GetColor(Dcolor));
     d7.AssignValueColor(GetColor(Dcolor));
     d8.AssignValueColor(GetColor(Dcolor));
     d9.AssignValueColor(GetColor(Dcolor));
    d10.AssignValueColor(GetColor(Dcolor));
     d1.HideBubble();
     d2.HideBubble();
     d3.HideBubble();
     d4.HideBubble();
     d5.HideBubble();
     d6.HideBubble();
     d7.HideBubble();
     d8.HideBubble();
     d9.HideBubble();
    d10.HideBubble();
     d1.HideTitle();
     d2.HideTitle();
     d3.HideTitle();
     d4.HideTitle();
     d5.HideTitle();
     d6.HideTitle();
     d7.HideTitle();
     d8.HideTitle();
     d9.HideTitle();
    d10.HideTitle();
addCloud(if CloudOn == yes
         then orl
         else double.nan
       , orl2,createColor(244,83,66), createColor(244,83,66));
addCloud(if CloudOn == yes
         then orl
         else double.nan
       , orh2,createColor(66,244,131), createColor(66,244,131));
# Begin Risk Algorithm
# First Breakout or Breakdown bars
  def Bubbleloc1 = isNaN(close[-1]);
  def BreakoutBar = if ORActive
                    then double.nan
                    else if !ORActive and c crosses above ORH2
                         then bar
                         else if !isNaN(BreakoutBar[1]) and c crosses ORH2
                              then BreakoutBar[1]
                    else BreakoutBar[1];
  def ATR = if ORActive2
  then Round((Average(TrueRange(h, c, l), nATR)) / TickSize(), 0) * TickSize()
  else ATR[1];
  def cond1 =  if h > ORH2 and
                  h[1] <= ORH2
               then Round((ORH2  + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
               else cond1[1];
plot ORLriskUP = if bar >= OREndBar and !ORActive and today
                 then HighestAll(ORH2ext - 2)
                 else double.nan;
     ORLriskUP.SetStyle(Curve.Long_Dash);
     ORLriskUP.SetDefaultColor(Color.Green);
     ORLriskUP.HideTitle();
  def crossUpBar = if close crosses above ORH2
                   then bar
                   else double.nan;
AddChartBubble(bar == HighestAll(crossUpBar), ORLriskUP, "RiskON ORH", color.green, no);
plot ORLriskDN = if bar >= OREndBar and !ORActive and close < ORL
                 then HighestAll(ORL2ext + 2)
                 else double.nan;
     ORLriskDN.SetStyle(Curve.Long_Dash);
     ORLriskDN.SetDefaultColor(Color.Red);
     ORLriskDN.HideTitle();
  def crossDnBar = if close crosses below ORL2ext
                   then bar
                   else double.nan;
AddChartBubble(bar == HighestAll(crossDnBar), HighestAll(ORLriskDN), "Risk ON ORL", color.red, yes);
# High Targets
plot Htarget = if bar >= BreakoutBar
               then cond1
               else double.nan;
     Htarget.SetPaintingStrategy(paintingStrategy.Squares);
     Htarget.SetLineWeight(1);
     Htarget.SetDefaultColor(Color.White);
     Htarget.HideTitle();
AddChartBubble(BubbleLoc1, Htarget, "RO", color.white, if c > Htarget then no else yes);
  def condHtarget2 = if c crosses above cond1
  then Round((cond1 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget2[1];
plot Htarget2 = if bar >= BreakoutBar
                then  condHtarget2
                else double.nan;
     Htarget2.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget2.SetLineWeight(1);
     Htarget2.SetDefaultColor(Color.Plum);
     Htarget2.HideTitle();
AddChartBubble(BubbleLoc1, Htarget2, "2nd T", color.plum, if c > Htarget2
                                                          then no
                                                          else yes);
  def condHtarget3 = if c crosses above condHtarget2
  then Round((condHtarget2 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget3[1];
plot Htarget3 = if bar >= BreakoutBar
                then condHtarget3
                else double.nan;
     Htarget3.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget3.SetLineWeight(1);
     Htarget3.SetDefaultColor(Color.Plum);
     Htarget3.HideTitle();
AddChartBubble(isNaN(C[-1]), Htarget3, "3rd T", color.plum, if c > Htarget3 then no else yes);
  def condHtarget4 = if c crosses above condHtarget3
  then Round((condHtarget3 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget4[1];
plot Htarget4 = if bar >= HighestAll(BreakoutBar)
                then condHtarget4
                else double.nan;
     Htarget4.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget4.SetLineWeight(1);
     Htarget4.SetDefaultColor(Color.Plum);
     Htarget4.HideTitle();
AddChartBubble(BubbleLoc1, Htarget4, "4th T", color.plum, if c > Htarget4 then no else yes);
  def condHtarget5 = if c crosses above condHtarget4
  then Round((condHtarget4 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget5[1];
plot Htarget5 = if bar >= BreakoutBar
                then condHtarget5
                else double.nan;
     Htarget5.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget5.SetLineWeight(1);
     Htarget5.SetDefaultColor(Color.Plum);
     Htarget5.HideTitle();
AddChartBubble(BubbleLoc1, Htarget5, "5th T", color.plum, if c > Htarget5 then no else yes);
# Low Targets
  def cond2 = if L < ORL2 and
                 L[1] >= ORL2
              then Round((ORL2  - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
              else cond2[1];
plot Ltarget =  if bar >= HighestAll(OREndBar)
                then highestAll(if isNaN(c[-1])
                                then cond2
                                else double.nan)
                else double.nan;
     Ltarget.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget.SetLineWeight(1);
     Ltarget.SetDefaultColor(Color.White);
     Ltarget.HideTitle();
AddChartBubble(BubbleLoc1, cond2, "RO", color.white, if c < Ltarget
                                                     then yes
                                                     else no);
  def condLtarget2 = if c crosses below cond2
  then Round((cond2 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget2[1];
plot Ltarget2 =  if bar >= HighestAll(OREndBar)
                 then highestAll(if isNaN(c[-1])
                                 then condLtarget2
                                 else double.nan)
                 else double.nan;
     Ltarget2.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget2.SetLineWeight(1);
     Ltarget2.SetDefaultColor(Color.Plum);
     Ltarget2.HideTitle();
AddChartBubble(BubbleLoc1, condLtarget2, "2nd T", color.plum, if c < condLtarget2
                                                              then yes
                                                              else no);
  def condLtarget3 = if c crosses below condLtarget2
  then Round((condLtarget2 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget3[1];
plot Ltarget3 = if bar >= HighestAll(OREndBar)
                then highestAll(if isNaN(c[-1])
                                then condLtarget3
                                else double.nan)
                else double.nan;
     Ltarget3.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget3.SetLineWeight(1);
     Ltarget3.SetDefaultColor(Color.Plum);
     Ltarget3.HideTitle();
AddChartBubble(BubbleLoc1, condLtarget3, "3rd T", color.plum, if c < Ltarget3
                                                              then yes
                                                              else no);
  def condLtarget4 = if c crosses condLtarget3
  then Round((condLtarget3 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget4[1];
plot Ltarget4 = if bar >= HighestAll(OREndBar)
                then highestAll(if isNaN(c[-1])
                                then condLtarget4
                                else double.nan)
                else double.nan;
     Ltarget4.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget4.SetLineWeight(1);
     Ltarget4.SetDefaultColor(Color.Plum);
     Ltarget4.HideTitle();
AddChartBubble(BubbleLoc1, condLtarget4, "4th T", color.plum, if c < Ltarget4
                                                              then yes
                                                              else no);
  def condLtarget5 = if c crosses condLtarget4
  then Round((condLtarget4 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget5[1];
plot Ltarget5 = if bar >= HighestAll(OREndBar)
                then highestAll(if isNaN(c[-1])
                                then condLtarget5
                                else double.nan)
                else double.nan;
     Ltarget5.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget5.SetLineWeight(1);
     Ltarget5.SetDefaultColor(Color.Plum);
     Ltarget5.HideTitle();
AddChartBubble(BubbleLoc1, condLtarget5, "5th T", color.plum, if c < Ltarget5
                                                              then yes
                                                              else no);
def last = if secondsTillTime(1600) == 0 and
              secondsFromTime(1600) == 0
           then c[1]
           else last[1];
plot LastClose = if Today and last != 0
                 then last
                 else Double.NaN;
     LastClose.SetPaintingStrategy(PaintingStrategy.Dashes);
     LastClose.SetDefaultColor(Color.White);
     LastClose.HideBubble();
     LastClose.HideTitle();
AddChartBubble(SecondsTillTime(0930) == 0, LastClose, "PC", color.gray, yes);
alert(c crosses above ORH2, "", Alert.Bar, Sound.Bell);
alert(c crosses below ORL2, "", Alert.Bar, Sound.Ring);

Here is an attempt I made with a bubble mover:


Code:
declare Hide_On_Daily;
declare Once_per_bar;

input showbubbles = yes;
input bubblemover = 8;
input OrMeanS  = 0930.0; #hint OrMeanS: Begin Mean Period. Usually Market Open EST.
input OrMeanE  = 0935.0; #hint OrMeanE: End Mean period. Usually End of first bar.
input OrBegin  = 0930.0; #hint OrBegin: Beginning for Period of Opening Range Breakout.
input OrEnd    = 1000.0; #hint OrEnd: End of Period of Opening Range Breakout.
input CloudOn  = no;     #hint CloudOn: Clouds Opening Range.
input AlertOn  = yes;    #hint AlertOn: Alerts on cross of Opening Range.
input ShowTodayOnly = {"No", default "Yes"}; 
input nAtr = 4;          #hint nATR: Lenght for the ATR Risk and Target Lines.
input AtrTargetMult = 2.0; #hint ATRmult: Multiplier for the ATR calculations.

  def h = high;
  def l = low;
  def c = close;
  def bar = barNumber();
  def s = ShowTodayOnly;
  def ORActive = if secondsTillTime(OrMeanE) > 0 and
                    secondsFromTime(OrMeanS) >= 0
                 then 1
                 else 0;
  def today = if s == 0
              or getDay() == getLastDay() and
                 secondsFromTime(OrMeanS) >= 0
              then 1
              else 0;
  def ORHigh = if ORHigh[1] == 0
               or ORActive[1] == 0 and
                  ORActive == 1
               then h
               else if ORActive and
                       h > ORHigh[1]
               then h
               else ORHigh[1];
  def ORLow = if ORLow[1] == 0
              or ORActive[1] == 0 and
                 ORActive == 1
              then l
              else if ORActive and
                      l < ORLow[1]
              then l
              else ORLow[1];
  def ORWidth = ORHigh - ORLow;
  def na = double.nan;
  def ORHA = if ORActive
             or today < 1
             then na
             else ORHigh;
  def ORLA = if ORActive
             or today < 1
             then na
             else ORLow;
  def O = ORHA - Round(((ORHA - ORLA) / 2) / TickSize(), 0) * TickSize();
  def ORActive2 = if secondsTillTime(OREnd) > 0 and
                     secondsFromTime(ORBegin) >= 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(OREnd) == 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);
plot ORLext = if barNumber() >= highestAll(ORmeanBar)
              then HighestAll(if isNaN(c[-1])
                              then ORL[1]
                              else double.nan)
              else double.nan;
     ORLext.SetDefaultColor(color.Yellow);
     ORLext.SetStyle(curve.Long_DASH);
     ORLext.SetLineWeight(3);
     ORLext.HideTitle();
  def ORH2 = if ORActive2
             or today < 1
             then na
             else ORHigh2;
plot ORH2ext = if barNumber() >= highestAll(ORendBar)
               then HighestAll(if isNaN(c[-1])
                               then ORH2[1]
                               else double.nan)
               else double.nan;
     ORH2ext.SetDefaultColor(color.Green);
     ORH2ext.SetStyle(curve.Long_DASH);
     ORH2ext.SetLineWeight(3);
     ORH2ext.HideTitle();
  def ORL2 = if ORActive2
               or today < 1
             then na
             else ORLow2;
plot ORL2ext = if barNumber() >= highestAll(ORendBar)
               then HighestAll(if isNaN(c[-1])
                               then ORL2[1]
                               else double.nan)
               else double.nan;
     ORL2ext.SetDefaultColor(color.Red);
     ORL2ext.SetStyle(curve.Long_DASH);
     ORL2ext.SetLineWeight(3);
     ORL2ext.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;
plot d1 = if (TimeLine , ORH2, na);
plot d2 = if (TimeLine , ORH2 - ( pos * 2), na);
plot d3 = if (TimeLine , ORH2 - ( pos * 3), na);
plot d4 = if (TimeLine , ORH2 - ( pos * 4), na);
plot d5 = if (TimeLine , ORH2 - ( pos * 5), na);
plot d6 = if (TimeLine , ORH2 - ( pos * 6), na);
plot d7 = if (TimeLine , ORH2 - ( pos * 7), na);
plot d8 = if (TimeLine , ORH2 - ( pos * 8), na);
plot d9 = if (TimeLine , ORH2 - ( pos * 9), na);
plot d10 = if (TimeLine ,(ORL2), na);
     d1.SetPaintingStrategy(PaintingStrategy.POINTS);
     d2.SetPaintingStrategy(PaintingStrategy.POINTS);
     d3.SetPaintingStrategy(PaintingStrategy.POINTS);
     d4.SetPaintingStrategy(PaintingStrategy.POINTS);
     d5.SetPaintingStrategy(PaintingStrategy.POINTS);
     d6.SetPaintingStrategy(PaintingStrategy.POINTS);
     d7.SetPaintingStrategy(PaintingStrategy.POINTS);
     d8.SetPaintingStrategy(PaintingStrategy.POINTS);
     d9.SetPaintingStrategy(PaintingStrategy.POINTS);
    d10.SetPaintingStrategy(PaintingStrategy.POINTS);
     d1.AssignValueColor(GetColor(Dcolor));
     d2.AssignValueColor(GetColor(Dcolor));
     d3.AssignValueColor(GetColor(Dcolor));
     d4.AssignValueColor(GetColor(Dcolor));
     d5.AssignValueColor(GetColor(Dcolor));
     d6.AssignValueColor(GetColor(Dcolor));
     d7.AssignValueColor(GetColor(Dcolor));
     d8.AssignValueColor(GetColor(Dcolor));
     d9.AssignValueColor(GetColor(Dcolor));
    d10.AssignValueColor(GetColor(Dcolor));
     d1.HideBubble();
     d2.HideBubble();
     d3.HideBubble();
     d4.HideBubble();
     d5.HideBubble();
     d6.HideBubble();
     d7.HideBubble();
     d8.HideBubble();
     d9.HideBubble();
    d10.HideBubble();
     d1.HideTitle();
     d2.HideTitle();
     d3.HideTitle();
     d4.HideTitle();
     d5.HideTitle();
     d6.HideTitle();
     d7.HideTitle();
     d8.HideTitle();
     d9.HideTitle();
    d10.HideTitle();
addCloud(if CloudOn == yes
         then orl
         else double.nan
       , orl2,createColor(244,83,66), createColor(244,83,66));
addCloud(if CloudOn == yes
         then orl
         else double.nan
       , orh2,createColor(66,244,131), createColor(66,244,131));
# Begin Risk Algorithm
# First Breakout or Breakdown bars
  def BUBBLESPOT = showbubbles and IsNaN(close) && !IsNaN(close);
  def BreakoutBar = if ORActive
                    then double.nan
                    else if !ORActive and c crosses above ORH2
                         then bar
                         else if !isNaN(BreakoutBar[1]) and c crosses ORH2
                              then BreakoutBar[1]
                    else BreakoutBar[1];
  def ATR = if ORActive2
  then Round((Average(TrueRange(h, c, l), nATR)) / TickSize(), 0) * TickSize()
  else ATR[1];
  def cond1 =  if h > ORH2 and
                  h[1] <= ORH2
               then Round((ORH2  + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
               else cond1[1];
plot ORLriskUP = if bar >= OREndBar and !ORActive and today
                 then HighestAll(ORH2ext - 2)
                 else double.nan;
     ORLriskUP.SetStyle(Curve.Long_Dash);
     ORLriskUP.SetDefaultColor(Color.Green);
     ORLriskUP.HideTitle();
  def crossUpBar = if close crosses above ORH2
                   then bar
                   else double.nan;
AddChartBubble(bar == HighestAll(crossUpBar), ORLriskUP, "RiskON ORH", color.green, no);
plot ORLriskDN = if bar >= OREndBar and !ORActive and close < ORL
                 then HighestAll(ORL2ext + 2)
                 else double.nan;
     ORLriskDN.SetStyle(Curve.Long_Dash);
     ORLriskDN.SetDefaultColor(Color.Red);
     ORLriskDN.HideTitle();
  def crossDnBar = if close crosses below ORL2ext
                   then bar
                   else double.nan;
AddChartBubble(bar == HighestAll(crossDnBar), HighestAll(ORLriskDN), "Risk ON ORL", color.red, yes);
# High Targets
plot Htarget = if bar >= BreakoutBar
               then cond1
               else double.nan;
     Htarget.SetPaintingStrategy(paintingStrategy.Squares);
     Htarget.SetLineWeight(1);
     Htarget.SetDefaultColor(Color.White);
     Htarget.HideTitle();
AddChartBubble(BUBBLESPOT, Htarget, "RO", color.white, if c > Htarget then no else yes);
  def condHtarget2 = if c crosses above cond1
  then Round((cond1 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget2[1];
plot Htarget2 = if bar >= BreakoutBar
                then  condHtarget2
                else double.nan;
     Htarget2.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget2.SetLineWeight(1);
     Htarget2.SetDefaultColor(Color.Plum);
     Htarget2.HideTitle();
AddChartBubble(BUBBLESPOT, Htarget2, "2nd T", color.plum, if c > Htarget2
                                                          then no
                                                          else yes);
  def condHtarget3 = if c crosses above condHtarget2
  then Round((condHtarget2 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget3[1];
plot Htarget3 = if bar >= BreakoutBar
                then condHtarget3
                else double.nan;
     Htarget3.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget3.SetLineWeight(1);
     Htarget3.SetDefaultColor(Color.Plum);
     Htarget3.HideTitle();
AddChartBubble(isNaN(C[-1]), Htarget3, "3rd T", color.plum, if c > Htarget3 then no else yes);
  def condHtarget4 = if c crosses above condHtarget3
  then Round((condHtarget3 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget4[1];
plot Htarget4 = if bar >= HighestAll(BreakoutBar)
                then condHtarget4
                else double.nan;
     Htarget4.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget4.SetLineWeight(1);
     Htarget4.SetDefaultColor(Color.Plum);
     Htarget4.HideTitle();
AddChartBubble(BUBBLESPOT, Htarget4, "4th T", color.plum, if c > Htarget4 then no else yes);
  def condHtarget5 = if c crosses above condHtarget4
  then Round((condHtarget4 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget5[1];
plot Htarget5 = if bar >= BreakoutBar
                then condHtarget5
                else double.nan;
     Htarget5.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget5.SetLineWeight(1);
     Htarget5.SetDefaultColor(Color.Plum);
     Htarget5.HideTitle();
AddChartBubble(BUBBLESPOT, Htarget5, "5th T", color.plum, if c > Htarget5 then no else yes);
# Low Targets
  def cond2 = if L < ORL2 and
                 L[1] >= ORL2
              then Round((ORL2  - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
              else cond2[1];
plot Ltarget =  if bar >= HighestAll(OREndBar)
                then highestAll(if isNaN(c[-1])
                                then cond2
                                else double.nan)
                else double.nan;
     Ltarget.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget.SetLineWeight(1);
     Ltarget.SetDefaultColor(Color.White);
     Ltarget.HideTitle();
AddChartBubble(BUBBLESPOT, cond2, "RO", color.white, if c < Ltarget
                                                     then yes
                                                     else no);
  def condLtarget2 = if c crosses below cond2
  then Round((cond2 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget2[1];
plot Ltarget2 =  if bar >= HighestAll(OREndBar)
                 then highestAll(if isNaN(c[-1])
                                 then condLtarget2
                                 else double.nan)
                 else double.nan;
     Ltarget2.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget2.SetLineWeight(1);
     Ltarget2.SetDefaultColor(Color.Plum);
     Ltarget2.HideTitle();
AddChartBubble(BUBBLESPOT, condLtarget2, "2nd T", color.plum, if c < condLtarget2
                                                              then yes
                                                              else no);
  def condLtarget3 = if c crosses below condLtarget2
  then Round((condLtarget2 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget3[1];
plot Ltarget3 = if bar >= HighestAll(OREndBar)
                then highestAll(if isNaN(c[-1])
                                then condLtarget3
                                else double.nan)
                else double.nan;
     Ltarget3.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget3.SetLineWeight(1);
     Ltarget3.SetDefaultColor(Color.Plum);
     Ltarget3.HideTitle();
AddChartBubble(BUBBLESPOT, condLtarget3, "3rd T", color.plum, if c < Ltarget3
                                                              then yes
                                                              else no);
  def condLtarget4 = if c crosses condLtarget3
  then Round((condLtarget3 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget4[1];
plot Ltarget4 = if bar >= HighestAll(OREndBar)
                then highestAll(if isNaN(c[-1])
                                then condLtarget4
                                else double.nan)
                else double.nan;
     Ltarget4.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget4.SetLineWeight(1);
     Ltarget4.SetDefaultColor(Color.Plum);
     Ltarget4.HideTitle();
AddChartBubble(BUBBLESPOT, condLtarget4, "4th T", color.plum, if c < Ltarget4
                                                              then yes
                                                              else no);
  def condLtarget5 = if c crosses condLtarget4
  then Round((condLtarget4 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget5[1];
plot Ltarget5 = if bar >= HighestAll(OREndBar)
                then highestAll(if isNaN(c[-1])
                                then condLtarget5
                                else double.nan)
                else double.nan;
     Ltarget5.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget5.SetLineWeight(1);
     Ltarget5.SetDefaultColor(Color.Plum);
     Ltarget5.HideTitle();
AddChartBubble(BUBBLESPOT, condLtarget5, "5th T", color.plum, if c < Ltarget5
                                                              then yes
                                                              else no);
def last = if secondsTillTime(1600) == 0 and
              secondsFromTime(1600) == 0
           then c[1]
           else last[1];
plot LastClose = if Today and last != 0
                 then last
                 else Double.NaN;
     LastClose.SetPaintingStrategy(PaintingStrategy.Dashes);
     LastClose.SetDefaultColor(Color.White);
     LastClose.HideBubble();
     LastClose.HideTitle();
AddChartBubble(SecondsTillTime(0930) == 0, LastClose, "PC", color.gray, yes);
alert(c crosses above ORH2, "", Alert.Bar, Sound.Bell);
alert(c crosses below ORL2, "", Alert.Bar, Sound.Ring);

#bubbles
def bm  = bubblemover;
def bm1 = bm + 1;


Any help is greatly appreciated!
 
uTS has good posts/threads on the Bubble Mover issue but I was not able to find a solution for a referenced symbol with it's value included in the bubble.
I am looking for 3 Inputs to control viewing of the Bubble Mover and it's Horizontal and Vertical positions from the Edit Studies and Strategies window.

Edit: removed == Yes from AddChartBubble(Bubble == Yes

This is what I was able to create so far and am now seeking assistance on the movement problem:

Kv1cUdy.png


Code:
declare lower;

input Bubble      = No;
input bubbleMoveH = 0; # Move Horizontal
input bubbleMoveV = 0; # Move Vertical

def Symbol = close("SPY");

plot Sym = Symbol;

def Data = if IsNaN(close[-1]) then Sym else Double.NaN;

def bMH  = bubbleMoveH;
def bMH1 = bMH + 1;
def bMV  = bubbleMoveV;

AddChartBubble(Bubble and isNaN(close[-1]) and !isNaN(close),
 Data, "SPY " + Round(Data,2),
 Sym.TakeValueColor());
 
Last edited:
uTS has good posts/threads on the Bubble Mover issue but I was not able to find a solution for a referenced symbol with it's value included in the bubble.
I am looking for 3 Inputs to control viewing of the Bubble Mover and it's Horizontal and Vertical positions from the Edit Studies and Strategies window.

Edit: removed == Yes from AddChartBubble(Bubble == Yes

This is what I was able to create so far and am now seeking assistance on the movement problem: hal_bub


Code:
declare lower;

input Bubble      = No;
input bubbleMoveH = 0; # Move Horizontal
input bubbleMoveV = 0; # Move Vertical

def Symbol = close("SPY");

plot Sym = Symbol;

def Data = if IsNaN(close[-1]) then Sym else Double.NaN;

def bMH  = bubbleMoveH;
def bMH1 = bMH + 1;
def bMV  = bubbleMoveV;

AddChartBubble(Bubble and isNaN(close[-1]) and !isNaN(close),
 Data, "SPY " + Round(Data,2),
 Sym.TakeValueColor());
hal_bubble

this allows user to move the bubble,
...before or after the last bar
...above or below the close of offset bar

on edit settings screen, there are 2 hints that describe the x and y inputs.

can change the reference symbol

Code:
#bubble_move_xy

#https://usethinkscript.com/threads/bubble-move-for-referenced-symbol-with-value.17249/

declare lower;

input Bubble = yes;
# ref last bar
input bubbleMoveH = -1;
#hint bubbleMoveH: Move bubble horizontally, a bar quantity. \n..positive numbers for a bar before the last bar.\n..negagive numbers for a bar after the last bar.
input bubbleMoveV = 0.0;
#hint bubbleMoveV: Move bubble Vertically, a dollar amount. \n..positive numbers move it up.\n..negagive numbers move it down.

input symbol = "SPY";
def Symbol_cls = close(symbol);

plot Sym = Symbol_cls;
sym.SetDefaultColor(Color.yellow);

def x = !IsNaN(close[(0+(-bubbleMoveH))]) and IsNaN(close[(-1+(-bubbleMoveH))]);
def clsy = if isnan(symbol_cls) then clsy[1] else symbol_cls;
def y = clsy + bubbleMoveV;

AddChartBubble(Bubble and x, y,
 symbol + " " + Round(y, 2),
 Sym.TakeValueColor());

addlabel(1, symbol, Sym.TakeValueColor());


#---------------------
input test_vert_line = no;
addverticalline(test_vert_line and x, "-");

input test_labels = yes;
addlabel(test_labels, bubbleMoveH + "  horz offset", color.yellow);
addlabel(test_labels, bubbleMovev + "  vertical offset", color.yellow);
#
 
Last edited:
Adding to halcyonguy's script I have modified the code to include green(up)/red(down) color to the line and bubble.
A gray extension line was included (modified from a previous halcyonguy script):
https://usethinkscript.com/threads/markos-stuck-on-comparison-chart.17202/#post-134514

The image shows SPY (once added they were dragged to upper chart) with 5 location variations compared against QQQ.
Moving the bubble into the future changes to ToS default color of cyan.
The lower chart is stand-alone SPY:

8DKX91D.png


If the code below should be enhanced/modified in any way please let me know as I am still learning thinkscript.

Code:
# https://usethinkscript.com/threads/bubble-move-for-referenced-symbol-with-value.17249/#post-134853
#bubble_move_xy
#https://usethinkscript.com/threads/bubble-move-for-referenced-symbol-with-value.17249/
#Carl_K December 2023: added green/red color to line and bubble, GRAY line extension

declare lower;

input Bubble = yes;
# ref last bar
input bubbleMoveH = 0;
#hint bubbleMoveH: Move bubble horizontally, a bar quantity.
# \n negagive numbers for a bar after the last bar.
# \n positive numbers for a bar before the last bar.
input bubbleMoveV = 0.0;
#hint bubbleMoveV: Move bubble Vertically, a dollar amount.
# \n negagive numbers move it down.
# \n positive numbers move it up.

input symbol = "SPY";
def Symbol_cls = close(symbol);

plot Sym = Symbol_cls;
Sym.DefineColor("Up", GetColor(6));
Sym.DefineColor("Down", GetColor(5));
Sym.AssignValueColor(if Sym > Sym[1] then Sym.Color("Up") else Sym.Color("Down"));
Sym.SetLineWeight(1);
Sym.SetStyle(1);
Sym.HideBubble();
Sym.HideTitle();

def x    = !IsNaN(close[(0+(bubbleMoveH))]) and IsNaN(close[(-1+(bubbleMoveH))]);
def clsy = if isnan(symbol_cls) then clsy[1] else symbol_cls;
def y    = clsy + bubbleMoveV;

AddChartBubble(Bubble and x, y,
 symbol + " " + Round(y, 2),
 Sym.TakeValueColor());

addlabel(1, symbol, Sym.TakeValueColor());


def k = 0;
def bubline = IsNaN(close[k + 0]) and !IsNaN(close[bubbleMoveH + 0]);
def w = if (bubble and !IsNaN(close[k]) and IsNaN(close[k - 1])) then Sym[k] else if bubline then w[1] else double.NaN;

plot zw = w;
zw.SetDefaultColor(Color.GRAY);
zw.SetLineWeight(1);


#---------------------
input test_vert_line = no;
addverticalline(test_vert_line and x, "-");

input test_labels = yes;
addlabel(test_labels, bubbleMoveH + "  horz offset", color.yellow);
addlabel(test_labels, bubbleMovev + "  vertical offset", color.yellow);
#
 
Last edited:
I think I've tried every formula for moving bubble on a chart but keep getting multiple bubbles instead of a single. I would like to move it +6 to right? This is my current part of chart where I have added bubble:

def pO = open(period = analysisPeriod);
plot periodOpen = if (!showAllPeriods and currentPeriod) or showAllPeriods then pO else Double.NaN;
periodOpen.AssignValueColor(GlobalColor("Period Open"));
periodOpen.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot static1 = periodopen;
static1.AssignValueColor(color.White);

def limit1 = !IsNaN(close) and IsNaN(close [-1] ) && HighestAll(BarNumber());

AddChartBubble(limit1, static1, "Period Open", Color.White);
 
I think I've tried every formula for moving bubble on a chart but keep getting multiple bubbles instead of a single. I would like to move it +6 to right? This is my current part of chart where I have added bubble:

def pO = open(period = analysisPeriod);
plot periodOpen = if (!showAllPeriods and currentPeriod) or showAllPeriods then pO else Double.NaN;
periodOpen.AssignValueColor(GlobalColor("Period Open"));
periodOpen.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot static1 = periodopen;
static1.AssignValueColor(color.White);

def limit1 = !IsNaN(close) and IsNaN(close [-1] ) && HighestAll(BarNumber());

AddChartBubble(limit1, static1, "Period Open", Color.White);

1. The bubblemover input moves the bubble sideways, both left and right by the number of bars input.
2. The !IsNaN(close[b+1]) and IsNaN(close ) added to limit1 with a bubblemover input of -1 are the same as !IsNaN(close) and IsNaN(close [-1]). This identifies the position of the current bar on the chart.
3. The image shows the bubble moved 6 spaces to the right of the current bar on the chart.
4. Make sure you have your expansion area set with enough bars to display the moved bubble.

Screenshot 2024-04-11 063652.png

Code:
def pO = open(period = aggregationPeriod.FIVE_MIN);
plot periodOpen = pO;
#if (!showAllPeriods and currentPeriod) or showAllPeriods then pO else Double.NaN; 
periodOpen.AssignValueColor(color.yellow);   #GlobalColor("Period Open"));
periodOpen.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot static1 = periodopen;
static1.AssignValueColor(color.White);

input bubblemover = 6;
def   b = bubblemover;
def limit1 = !IsNaN(close[b+1]) and IsNaN(close [b] );# && HighestAll(BarNumber());

AddChartBubble(limit1, static1[b+1], "Period Open", Color.White);

#
 
1. The bubblemover input moves the bubble sideways, both left and right by the number of bars input.
2. The !IsNaN(close[b+1]) and IsNaN(close ) added to limit1 with a bubblemover input of -1 are the same as !IsNaN(close) and IsNaN(close [-1]). This identifies the position of the current bar on the chart.
3. The image shows the bubble moved 6 spaces to the right of the current bar on the chart.
4. Make sure you have your expansion area set with enough bars to display the moved bubble.
Thank you very much
 
View attachment 18803Hey man, no rush on this, but I have been trying to figure out how to move any instance of a bubble within an ORB script, but I am not having any luck. Even Chatgpt's 22 attempts didnt work :LOL: . If you look at the screenshot, I would like all of those instances of a bubble, moved to the right 8 bars or so

Here is the original code:

Code:
declare Hide_On_Daily;
declare Once_per_bar;


input OrMeanS  = 0930.0; #hint OrMeanS: Begin Mean Period. Usually Market Open EST.
input OrMeanE  = 0935.0; #hint OrMeanE: End Mean period. Usually End of first bar.
input OrBegin  = 0930.0; #hint OrBegin: Beginning for Period of Opening Range Breakout.
input OrEnd    = 1000.0; #hint OrEnd: End of Period of Opening Range Breakout.
input CloudOn  = no;     #hint CloudOn: Clouds Opening Range.
input AlertOn  = yes;    #hint AlertOn: Alerts on cross of Opening Range.
input ShowTodayOnly = {"No", default "Yes"};
input nAtr = 4;          #hint nATR: Lenght for the ATR Risk and Target Lines.
input AtrTargetMult = 2.0; #hint ATRmult: Multiplier for the ATR calculations.

  def h = high;
  def l = low;
  def c = close;
  def bar = barNumber();
  def s = ShowTodayOnly;
  def ORActive = if secondsTillTime(OrMeanE) > 0 and
                    secondsFromTime(OrMeanS) >= 0
                 then 1
                 else 0;
  def today = if s == 0
              or getDay() == getLastDay() and
                 secondsFromTime(OrMeanS) >= 0
              then 1
              else 0;
  def ORHigh = if ORHigh[1] == 0
               or ORActive[1] == 0 and
                  ORActive == 1
               then h
               else if ORActive and
                       h > ORHigh[1]
               then h
               else ORHigh[1];
  def ORLow = if ORLow[1] == 0
              or ORActive[1] == 0 and
                 ORActive == 1
              then l
              else if ORActive and
                      l < ORLow[1]
              then l
              else ORLow[1];
  def ORWidth = ORHigh - ORLow;
  def na = double.nan;
  def ORHA = if ORActive
             or today < 1
             then na
             else ORHigh;
  def ORLA = if ORActive
             or today < 1
             then na
             else ORLow;
  def O = ORHA - Round(((ORHA - ORLA) / 2) / TickSize(), 0) * TickSize();
  def ORActive2 = if secondsTillTime(OREnd) > 0 and
                     secondsFromTime(ORBegin) >= 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(OREnd) == 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);
plot ORLext = if barNumber() >= highestAll(ORmeanBar)
              then HighestAll(if isNaN(c[-1])
                              then ORL[1]
                              else double.nan)
              else double.nan;
     ORLext.SetDefaultColor(color.Yellow);
     ORLext.SetStyle(curve.Long_DASH);
     ORLext.SetLineWeight(3);
     ORLext.HideTitle();
  def ORH2 = if ORActive2
             or today < 1
             then na
             else ORHigh2;
plot ORH2ext = if barNumber() >= highestAll(ORendBar)
               then HighestAll(if isNaN(c[-1])
                               then ORH2[1]
                               else double.nan)
               else double.nan;
     ORH2ext.SetDefaultColor(color.Green);
     ORH2ext.SetStyle(curve.Long_DASH);
     ORH2ext.SetLineWeight(3);
     ORH2ext.HideTitle();
  def ORL2 = if ORActive2
               or today < 1
             then na
             else ORLow2;
plot ORL2ext = if barNumber() >= highestAll(ORendBar)
               then HighestAll(if isNaN(c[-1])
                               then ORL2[1]
                               else double.nan)
               else double.nan;
     ORL2ext.SetDefaultColor(color.Red);
     ORL2ext.SetStyle(curve.Long_DASH);
     ORL2ext.SetLineWeight(3);
     ORL2ext.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;
plot d1 = if (TimeLine , ORH2, na);
plot d2 = if (TimeLine , ORH2 - ( pos * 2), na);
plot d3 = if (TimeLine , ORH2 - ( pos * 3), na);
plot d4 = if (TimeLine , ORH2 - ( pos * 4), na);
plot d5 = if (TimeLine , ORH2 - ( pos * 5), na);
plot d6 = if (TimeLine , ORH2 - ( pos * 6), na);
plot d7 = if (TimeLine , ORH2 - ( pos * 7), na);
plot d8 = if (TimeLine , ORH2 - ( pos * 8), na);
plot d9 = if (TimeLine , ORH2 - ( pos * 9), na);
plot d10 = if (TimeLine ,(ORL2), na);
     d1.SetPaintingStrategy(PaintingStrategy.POINTS);
     d2.SetPaintingStrategy(PaintingStrategy.POINTS);
     d3.SetPaintingStrategy(PaintingStrategy.POINTS);
     d4.SetPaintingStrategy(PaintingStrategy.POINTS);
     d5.SetPaintingStrategy(PaintingStrategy.POINTS);
     d6.SetPaintingStrategy(PaintingStrategy.POINTS);
     d7.SetPaintingStrategy(PaintingStrategy.POINTS);
     d8.SetPaintingStrategy(PaintingStrategy.POINTS);
     d9.SetPaintingStrategy(PaintingStrategy.POINTS);
    d10.SetPaintingStrategy(PaintingStrategy.POINTS);
     d1.AssignValueColor(GetColor(Dcolor));
     d2.AssignValueColor(GetColor(Dcolor));
     d3.AssignValueColor(GetColor(Dcolor));
     d4.AssignValueColor(GetColor(Dcolor));
     d5.AssignValueColor(GetColor(Dcolor));
     d6.AssignValueColor(GetColor(Dcolor));
     d7.AssignValueColor(GetColor(Dcolor));
     d8.AssignValueColor(GetColor(Dcolor));
     d9.AssignValueColor(GetColor(Dcolor));
    d10.AssignValueColor(GetColor(Dcolor));
     d1.HideBubble();
     d2.HideBubble();
     d3.HideBubble();
     d4.HideBubble();
     d5.HideBubble();
     d6.HideBubble();
     d7.HideBubble();
     d8.HideBubble();
     d9.HideBubble();
    d10.HideBubble();
     d1.HideTitle();
     d2.HideTitle();
     d3.HideTitle();
     d4.HideTitle();
     d5.HideTitle();
     d6.HideTitle();
     d7.HideTitle();
     d8.HideTitle();
     d9.HideTitle();
    d10.HideTitle();
addCloud(if CloudOn == yes
         then orl
         else double.nan
       , orl2,createColor(244,83,66), createColor(244,83,66));
addCloud(if CloudOn == yes
         then orl
         else double.nan
       , orh2,createColor(66,244,131), createColor(66,244,131));
# Begin Risk Algorithm
# First Breakout or Breakdown bars
  def Bubbleloc1 = isNaN(close[-1]);
  def BreakoutBar = if ORActive
                    then double.nan
                    else if !ORActive and c crosses above ORH2
                         then bar
                         else if !isNaN(BreakoutBar[1]) and c crosses ORH2
                              then BreakoutBar[1]
                    else BreakoutBar[1];
  def ATR = if ORActive2
  then Round((Average(TrueRange(h, c, l), nATR)) / TickSize(), 0) * TickSize()
  else ATR[1];
  def cond1 =  if h > ORH2 and
                  h[1] <= ORH2
               then Round((ORH2  + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
               else cond1[1];
plot ORLriskUP = if bar >= OREndBar and !ORActive and today
                 then HighestAll(ORH2ext - 2)
                 else double.nan;
     ORLriskUP.SetStyle(Curve.Long_Dash);
     ORLriskUP.SetDefaultColor(Color.Green);
     ORLriskUP.HideTitle();
  def crossUpBar = if close crosses above ORH2
                   then bar
                   else double.nan;
AddChartBubble(bar == HighestAll(crossUpBar), ORLriskUP, "RiskON ORH", color.green, no);
plot ORLriskDN = if bar >= OREndBar and !ORActive and close < ORL
                 then HighestAll(ORL2ext + 2)
                 else double.nan;
     ORLriskDN.SetStyle(Curve.Long_Dash);
     ORLriskDN.SetDefaultColor(Color.Red);
     ORLriskDN.HideTitle();
  def crossDnBar = if close crosses below ORL2ext
                   then bar
                   else double.nan;
AddChartBubble(bar == HighestAll(crossDnBar), HighestAll(ORLriskDN), "Risk ON ORL", color.red, yes);
# High Targets
plot Htarget = if bar >= BreakoutBar
               then cond1
               else double.nan;
     Htarget.SetPaintingStrategy(paintingStrategy.Squares);
     Htarget.SetLineWeight(1);
     Htarget.SetDefaultColor(Color.White);
     Htarget.HideTitle();
AddChartBubble(BubbleLoc1, Htarget, "RO", color.white, if c > Htarget then no else yes);
  def condHtarget2 = if c crosses above cond1
  then Round((cond1 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget2[1];
plot Htarget2 = if bar >= BreakoutBar
                then  condHtarget2
                else double.nan;
     Htarget2.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget2.SetLineWeight(1);
     Htarget2.SetDefaultColor(Color.Plum);
     Htarget2.HideTitle();
AddChartBubble(BubbleLoc1, Htarget2, "2nd T", color.plum, if c > Htarget2
                                                          then no
                                                          else yes);
  def condHtarget3 = if c crosses above condHtarget2
  then Round((condHtarget2 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget3[1];
plot Htarget3 = if bar >= BreakoutBar
                then condHtarget3
                else double.nan;
     Htarget3.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget3.SetLineWeight(1);
     Htarget3.SetDefaultColor(Color.Plum);
     Htarget3.HideTitle();
AddChartBubble(isNaN(C[-1]), Htarget3, "3rd T", color.plum, if c > Htarget3 then no else yes);
  def condHtarget4 = if c crosses above condHtarget3
  then Round((condHtarget3 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget4[1];
plot Htarget4 = if bar >= HighestAll(BreakoutBar)
                then condHtarget4
                else double.nan;
     Htarget4.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget4.SetLineWeight(1);
     Htarget4.SetDefaultColor(Color.Plum);
     Htarget4.HideTitle();
AddChartBubble(BubbleLoc1, Htarget4, "4th T", color.plum, if c > Htarget4 then no else yes);
  def condHtarget5 = if c crosses above condHtarget4
  then Round((condHtarget4 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget5[1];
plot Htarget5 = if bar >= BreakoutBar
                then condHtarget5
                else double.nan;
     Htarget5.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget5.SetLineWeight(1);
     Htarget5.SetDefaultColor(Color.Plum);
     Htarget5.HideTitle();
AddChartBubble(BubbleLoc1, Htarget5, "5th T", color.plum, if c > Htarget5 then no else yes);
# Low Targets
  def cond2 = if L < ORL2 and
                 L[1] >= ORL2
              then Round((ORL2  - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
              else cond2[1];
plot Ltarget =  if bar >= HighestAll(OREndBar)
                then highestAll(if isNaN(c[-1])
                                then cond2
                                else double.nan)
                else double.nan;
     Ltarget.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget.SetLineWeight(1);
     Ltarget.SetDefaultColor(Color.White);
     Ltarget.HideTitle();
AddChartBubble(BubbleLoc1, cond2, "RO", color.white, if c < Ltarget
                                                     then yes
                                                     else no);
  def condLtarget2 = if c crosses below cond2
  then Round((cond2 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget2[1];
plot Ltarget2 =  if bar >= HighestAll(OREndBar)
                 then highestAll(if isNaN(c[-1])
                                 then condLtarget2
                                 else double.nan)
                 else double.nan;
     Ltarget2.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget2.SetLineWeight(1);
     Ltarget2.SetDefaultColor(Color.Plum);
     Ltarget2.HideTitle();
AddChartBubble(BubbleLoc1, condLtarget2, "2nd T", color.plum, if c < condLtarget2
                                                              then yes
                                                              else no);
  def condLtarget3 = if c crosses below condLtarget2
  then Round((condLtarget2 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget3[1];
plot Ltarget3 = if bar >= HighestAll(OREndBar)
                then highestAll(if isNaN(c[-1])
                                then condLtarget3
                                else double.nan)
                else double.nan;
     Ltarget3.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget3.SetLineWeight(1);
     Ltarget3.SetDefaultColor(Color.Plum);
     Ltarget3.HideTitle();
AddChartBubble(BubbleLoc1, condLtarget3, "3rd T", color.plum, if c < Ltarget3
                                                              then yes
                                                              else no);
  def condLtarget4 = if c crosses condLtarget3
  then Round((condLtarget3 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget4[1];
plot Ltarget4 = if bar >= HighestAll(OREndBar)
                then highestAll(if isNaN(c[-1])
                                then condLtarget4
                                else double.nan)
                else double.nan;
     Ltarget4.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget4.SetLineWeight(1);
     Ltarget4.SetDefaultColor(Color.Plum);
     Ltarget4.HideTitle();
AddChartBubble(BubbleLoc1, condLtarget4, "4th T", color.plum, if c < Ltarget4
                                                              then yes
                                                              else no);
  def condLtarget5 = if c crosses condLtarget4
  then Round((condLtarget4 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget5[1];
plot Ltarget5 = if bar >= HighestAll(OREndBar)
                then highestAll(if isNaN(c[-1])
                                then condLtarget5
                                else double.nan)
                else double.nan;
     Ltarget5.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget5.SetLineWeight(1);
     Ltarget5.SetDefaultColor(Color.Plum);
     Ltarget5.HideTitle();
AddChartBubble(BubbleLoc1, condLtarget5, "5th T", color.plum, if c < Ltarget5
                                                              then yes
                                                              else no);
def last = if secondsTillTime(1600) == 0 and
              secondsFromTime(1600) == 0
           then c[1]
           else last[1];
plot LastClose = if Today and last != 0
                 then last
                 else Double.NaN;
     LastClose.SetPaintingStrategy(PaintingStrategy.Dashes);
     LastClose.SetDefaultColor(Color.White);
     LastClose.HideBubble();
     LastClose.HideTitle();
AddChartBubble(SecondsTillTime(0930) == 0, LastClose, "PC", color.gray, yes);
alert(c crosses above ORH2, "", Alert.Bar, Sound.Bell);
alert(c crosses below ORL2, "", Alert.Bar, Sound.Ring);

Here is an attempt I made with a bubble mover:


Code:
declare Hide_On_Daily;
declare Once_per_bar;

input showbubbles = yes;
input bubblemover = 8;
input OrMeanS  = 0930.0; #hint OrMeanS: Begin Mean Period. Usually Market Open EST.
input OrMeanE  = 0935.0; #hint OrMeanE: End Mean period. Usually End of first bar.
input OrBegin  = 0930.0; #hint OrBegin: Beginning for Period of Opening Range Breakout.
input OrEnd    = 1000.0; #hint OrEnd: End of Period of Opening Range Breakout.
input CloudOn  = no;     #hint CloudOn: Clouds Opening Range.
input AlertOn  = yes;    #hint AlertOn: Alerts on cross of Opening Range.
input ShowTodayOnly = {"No", default "Yes"};
input nAtr = 4;          #hint nATR: Lenght for the ATR Risk and Target Lines.
input AtrTargetMult = 2.0; #hint ATRmult: Multiplier for the ATR calculations.

  def h = high;
  def l = low;
  def c = close;
  def bar = barNumber();
  def s = ShowTodayOnly;
  def ORActive = if secondsTillTime(OrMeanE) > 0 and
                    secondsFromTime(OrMeanS) >= 0
                 then 1
                 else 0;
  def today = if s == 0
              or getDay() == getLastDay() and
                 secondsFromTime(OrMeanS) >= 0
              then 1
              else 0;
  def ORHigh = if ORHigh[1] == 0
               or ORActive[1] == 0 and
                  ORActive == 1
               then h
               else if ORActive and
                       h > ORHigh[1]
               then h
               else ORHigh[1];
  def ORLow = if ORLow[1] == 0
              or ORActive[1] == 0 and
                 ORActive == 1
              then l
              else if ORActive and
                      l < ORLow[1]
              then l
              else ORLow[1];
  def ORWidth = ORHigh - ORLow;
  def na = double.nan;
  def ORHA = if ORActive
             or today < 1
             then na
             else ORHigh;
  def ORLA = if ORActive
             or today < 1
             then na
             else ORLow;
  def O = ORHA - Round(((ORHA - ORLA) / 2) / TickSize(), 0) * TickSize();
  def ORActive2 = if secondsTillTime(OREnd) > 0 and
                     secondsFromTime(ORBegin) >= 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(OREnd) == 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);
plot ORLext = if barNumber() >= highestAll(ORmeanBar)
              then HighestAll(if isNaN(c[-1])
                              then ORL[1]
                              else double.nan)
              else double.nan;
     ORLext.SetDefaultColor(color.Yellow);
     ORLext.SetStyle(curve.Long_DASH);
     ORLext.SetLineWeight(3);
     ORLext.HideTitle();
  def ORH2 = if ORActive2
             or today < 1
             then na
             else ORHigh2;
plot ORH2ext = if barNumber() >= highestAll(ORendBar)
               then HighestAll(if isNaN(c[-1])
                               then ORH2[1]
                               else double.nan)
               else double.nan;
     ORH2ext.SetDefaultColor(color.Green);
     ORH2ext.SetStyle(curve.Long_DASH);
     ORH2ext.SetLineWeight(3);
     ORH2ext.HideTitle();
  def ORL2 = if ORActive2
               or today < 1
             then na
             else ORLow2;
plot ORL2ext = if barNumber() >= highestAll(ORendBar)
               then HighestAll(if isNaN(c[-1])
                               then ORL2[1]
                               else double.nan)
               else double.nan;
     ORL2ext.SetDefaultColor(color.Red);
     ORL2ext.SetStyle(curve.Long_DASH);
     ORL2ext.SetLineWeight(3);
     ORL2ext.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;
plot d1 = if (TimeLine , ORH2, na);
plot d2 = if (TimeLine , ORH2 - ( pos * 2), na);
plot d3 = if (TimeLine , ORH2 - ( pos * 3), na);
plot d4 = if (TimeLine , ORH2 - ( pos * 4), na);
plot d5 = if (TimeLine , ORH2 - ( pos * 5), na);
plot d6 = if (TimeLine , ORH2 - ( pos * 6), na);
plot d7 = if (TimeLine , ORH2 - ( pos * 7), na);
plot d8 = if (TimeLine , ORH2 - ( pos * 8), na);
plot d9 = if (TimeLine , ORH2 - ( pos * 9), na);
plot d10 = if (TimeLine ,(ORL2), na);
     d1.SetPaintingStrategy(PaintingStrategy.POINTS);
     d2.SetPaintingStrategy(PaintingStrategy.POINTS);
     d3.SetPaintingStrategy(PaintingStrategy.POINTS);
     d4.SetPaintingStrategy(PaintingStrategy.POINTS);
     d5.SetPaintingStrategy(PaintingStrategy.POINTS);
     d6.SetPaintingStrategy(PaintingStrategy.POINTS);
     d7.SetPaintingStrategy(PaintingStrategy.POINTS);
     d8.SetPaintingStrategy(PaintingStrategy.POINTS);
     d9.SetPaintingStrategy(PaintingStrategy.POINTS);
    d10.SetPaintingStrategy(PaintingStrategy.POINTS);
     d1.AssignValueColor(GetColor(Dcolor));
     d2.AssignValueColor(GetColor(Dcolor));
     d3.AssignValueColor(GetColor(Dcolor));
     d4.AssignValueColor(GetColor(Dcolor));
     d5.AssignValueColor(GetColor(Dcolor));
     d6.AssignValueColor(GetColor(Dcolor));
     d7.AssignValueColor(GetColor(Dcolor));
     d8.AssignValueColor(GetColor(Dcolor));
     d9.AssignValueColor(GetColor(Dcolor));
    d10.AssignValueColor(GetColor(Dcolor));
     d1.HideBubble();
     d2.HideBubble();
     d3.HideBubble();
     d4.HideBubble();
     d5.HideBubble();
     d6.HideBubble();
     d7.HideBubble();
     d8.HideBubble();
     d9.HideBubble();
    d10.HideBubble();
     d1.HideTitle();
     d2.HideTitle();
     d3.HideTitle();
     d4.HideTitle();
     d5.HideTitle();
     d6.HideTitle();
     d7.HideTitle();
     d8.HideTitle();
     d9.HideTitle();
    d10.HideTitle();
addCloud(if CloudOn == yes
         then orl
         else double.nan
       , orl2,createColor(244,83,66), createColor(244,83,66));
addCloud(if CloudOn == yes
         then orl
         else double.nan
       , orh2,createColor(66,244,131), createColor(66,244,131));
# Begin Risk Algorithm
# First Breakout or Breakdown bars
  def BUBBLESPOT = showbubbles and IsNaN(close) && !IsNaN(close);
  def BreakoutBar = if ORActive
                    then double.nan
                    else if !ORActive and c crosses above ORH2
                         then bar
                         else if !isNaN(BreakoutBar[1]) and c crosses ORH2
                              then BreakoutBar[1]
                    else BreakoutBar[1];
  def ATR = if ORActive2
  then Round((Average(TrueRange(h, c, l), nATR)) / TickSize(), 0) * TickSize()
  else ATR[1];
  def cond1 =  if h > ORH2 and
                  h[1] <= ORH2
               then Round((ORH2  + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
               else cond1[1];
plot ORLriskUP = if bar >= OREndBar and !ORActive and today
                 then HighestAll(ORH2ext - 2)
                 else double.nan;
     ORLriskUP.SetStyle(Curve.Long_Dash);
     ORLriskUP.SetDefaultColor(Color.Green);
     ORLriskUP.HideTitle();
  def crossUpBar = if close crosses above ORH2
                   then bar
                   else double.nan;
AddChartBubble(bar == HighestAll(crossUpBar), ORLriskUP, "RiskON ORH", color.green, no);
plot ORLriskDN = if bar >= OREndBar and !ORActive and close < ORL
                 then HighestAll(ORL2ext + 2)
                 else double.nan;
     ORLriskDN.SetStyle(Curve.Long_Dash);
     ORLriskDN.SetDefaultColor(Color.Red);
     ORLriskDN.HideTitle();
  def crossDnBar = if close crosses below ORL2ext
                   then bar
                   else double.nan;
AddChartBubble(bar == HighestAll(crossDnBar), HighestAll(ORLriskDN), "Risk ON ORL", color.red, yes);
# High Targets
plot Htarget = if bar >= BreakoutBar
               then cond1
               else double.nan;
     Htarget.SetPaintingStrategy(paintingStrategy.Squares);
     Htarget.SetLineWeight(1);
     Htarget.SetDefaultColor(Color.White);
     Htarget.HideTitle();
AddChartBubble(BUBBLESPOT, Htarget, "RO", color.white, if c > Htarget then no else yes);
  def condHtarget2 = if c crosses above cond1
  then Round((cond1 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget2[1];
plot Htarget2 = if bar >= BreakoutBar
                then  condHtarget2
                else double.nan;
     Htarget2.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget2.SetLineWeight(1);
     Htarget2.SetDefaultColor(Color.Plum);
     Htarget2.HideTitle();
AddChartBubble(BUBBLESPOT, Htarget2, "2nd T", color.plum, if c > Htarget2
                                                          then no
                                                          else yes);
  def condHtarget3 = if c crosses above condHtarget2
  then Round((condHtarget2 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget3[1];
plot Htarget3 = if bar >= BreakoutBar
                then condHtarget3
                else double.nan;
     Htarget3.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget3.SetLineWeight(1);
     Htarget3.SetDefaultColor(Color.Plum);
     Htarget3.HideTitle();
AddChartBubble(isNaN(C[-1]), Htarget3, "3rd T", color.plum, if c > Htarget3 then no else yes);
  def condHtarget4 = if c crosses above condHtarget3
  then Round((condHtarget3 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget4[1];
plot Htarget4 = if bar >= HighestAll(BreakoutBar)
                then condHtarget4
                else double.nan;
     Htarget4.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget4.SetLineWeight(1);
     Htarget4.SetDefaultColor(Color.Plum);
     Htarget4.HideTitle();
AddChartBubble(BUBBLESPOT, Htarget4, "4th T", color.plum, if c > Htarget4 then no else yes);
  def condHtarget5 = if c crosses above condHtarget4
  then Round((condHtarget4 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget5[1];
plot Htarget5 = if bar >= BreakoutBar
                then condHtarget5
                else double.nan;
     Htarget5.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget5.SetLineWeight(1);
     Htarget5.SetDefaultColor(Color.Plum);
     Htarget5.HideTitle();
AddChartBubble(BUBBLESPOT, Htarget5, "5th T", color.plum, if c > Htarget5 then no else yes);
# Low Targets
  def cond2 = if L < ORL2 and
                 L[1] >= ORL2
              then Round((ORL2  - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
              else cond2[1];
plot Ltarget =  if bar >= HighestAll(OREndBar)
                then highestAll(if isNaN(c[-1])
                                then cond2
                                else double.nan)
                else double.nan;
     Ltarget.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget.SetLineWeight(1);
     Ltarget.SetDefaultColor(Color.White);
     Ltarget.HideTitle();
AddChartBubble(BUBBLESPOT, cond2, "RO", color.white, if c < Ltarget
                                                     then yes
                                                     else no);
  def condLtarget2 = if c crosses below cond2
  then Round((cond2 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget2[1];
plot Ltarget2 =  if bar >= HighestAll(OREndBar)
                 then highestAll(if isNaN(c[-1])
                                 then condLtarget2
                                 else double.nan)
                 else double.nan;
     Ltarget2.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget2.SetLineWeight(1);
     Ltarget2.SetDefaultColor(Color.Plum);
     Ltarget2.HideTitle();
AddChartBubble(BUBBLESPOT, condLtarget2, "2nd T", color.plum, if c < condLtarget2
                                                              then yes
                                                              else no);
  def condLtarget3 = if c crosses below condLtarget2
  then Round((condLtarget2 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget3[1];
plot Ltarget3 = if bar >= HighestAll(OREndBar)
                then highestAll(if isNaN(c[-1])
                                then condLtarget3
                                else double.nan)
                else double.nan;
     Ltarget3.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget3.SetLineWeight(1);
     Ltarget3.SetDefaultColor(Color.Plum);
     Ltarget3.HideTitle();
AddChartBubble(BUBBLESPOT, condLtarget3, "3rd T", color.plum, if c < Ltarget3
                                                              then yes
                                                              else no);
  def condLtarget4 = if c crosses condLtarget3
  then Round((condLtarget3 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget4[1];
plot Ltarget4 = if bar >= HighestAll(OREndBar)
                then highestAll(if isNaN(c[-1])
                                then condLtarget4
                                else double.nan)
                else double.nan;
     Ltarget4.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget4.SetLineWeight(1);
     Ltarget4.SetDefaultColor(Color.Plum);
     Ltarget4.HideTitle();
AddChartBubble(BUBBLESPOT, condLtarget4, "4th T", color.plum, if c < Ltarget4
                                                              then yes
                                                              else no);
  def condLtarget5 = if c crosses condLtarget4
  then Round((condLtarget4 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget5[1];
plot Ltarget5 = if bar >= HighestAll(OREndBar)
                then highestAll(if isNaN(c[-1])
                                then condLtarget5
                                else double.nan)
                else double.nan;
     Ltarget5.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget5.SetLineWeight(1);
     Ltarget5.SetDefaultColor(Color.Plum);
     Ltarget5.HideTitle();
AddChartBubble(BUBBLESPOT, condLtarget5, "5th T", color.plum, if c < Ltarget5
                                                              then yes
                                                              else no);
def last = if secondsTillTime(1600) == 0 and
              secondsFromTime(1600) == 0
           then c[1]
           else last[1];
plot LastClose = if Today and last != 0
                 then last
                 else Double.NaN;
     LastClose.SetPaintingStrategy(PaintingStrategy.Dashes);
     LastClose.SetDefaultColor(Color.White);
     LastClose.HideBubble();
     LastClose.HideTitle();
AddChartBubble(SecondsTillTime(0930) == 0, LastClose, "PC", color.gray, yes);
alert(c crosses above ORH2, "", Alert.Bar, Sound.Bell);
alert(c crosses below ORL2, "", Alert.Bar, Sound.Ring);

#bubbles
def bm  = bubblemover;
def bm1 = bm + 1;


Any help is greatly appreciated!

Just saw this.

Here is an example from the full revised code below on how to move the bubbles using the code you added.

1. The input bubblemover moves the bubbles sideways the number of bars input.
2. Both bm and bm1 are used within bubblespot to dynamically locate where to place the bubble
3. Bubblespot is indicating, with bubblemover set to 2, that the 2nd bar in the expansion (isNaN(close[bm])) is where to place the bubble . It is then necessary to locate the area within the chart (!isNaN(close[bm1]) where the data is located.
3a. Then the addchartbubble's Htarget[bm1] would be where to find the data Bubblepot identified (!isNaN(close[bm1])

Bubblemover Example Code
Code:
input bubblemover = 2;
def bm  = bubblemover;
def bm1 = bm + 1;
def BUBBLESPOT = showbubbles and IsNaN(close[bm]) && !IsNaN(close[bm1]);
AddChartBubble(BUBBLESPOT, Htarget[bm1], "RO", Color.WHITE, if c > Htarget then no else yes);[

4. Without the bubblemover code, bubblespot and addchart would look like this
def BUBBLESPOT = showbubbles and IsNaN(close[2]) && !IsNaN(close[3]);
AddChartBubble(BUBBLESPOT, Htarget[3], "RO", Color.WHITE, if c > Htarget then no else yes);

5.If you wanted to move the bubbles 4 bars to the right instead of 2, you would have to change the numbers manually from 2/3 to 4/5 for each addchartbubble code.
def BUBBLESPOT = showbubbles and IsNaN(close[4]) && !IsNaN(close[5]);
AddChartBubble(BUBBLESPOT, Htarget[5], "RO", Color.WHITE, if c > Htarget then no else yes);

6. If you wanted to change from 2 bars to 4 bars movement, with bubblemover code, you would just change the input bubblemover to 4.

Here is the full revised code
Screenshot 2024-08-03 160916.png
Code:
declare hide_on_daily;
declare once_per_bar;

input showbubbles = yes;

input OrMeanS  = 0930.0; #hint OrMeanS: Begin Mean Period. Usually Market Open EST.
input OrMeanE  = 0935.0; #hint OrMeanE: End Mean period. Usually End of first bar.
input OrBegin  = 0930.0; #hint OrBegin: Beginning for Period of Opening Range Breakout.
input OrEnd    = 1000.0; #hint OrEnd: End of Period of Opening Range Breakout.
input CloudOn  = no;     #hint CloudOn: Clouds Opening Range.
input AlertOn  = yes;    #hint AlertOn: Alerts on cross of Opening Range.
input ShowTodayOnly = {"No", default "Yes"};
input nAtr = 4;          #hint nATR: Lenght for the ATR Risk and Target Lines.
input AtrTargetMult = 2.0; #hint ATRmult: Multiplier for the ATR calculations.

def h = high;
def l = low;
def c = close;
def bar = BarNumber();
def s = ShowTodayOnly;
def ORActive = if SecondsTillTime(OrMeanE) > 0 and
                    SecondsFromTime(OrMeanS) >= 0
                 then 1
                 else 0;
def today = if s == 0
              or GetDay() == GetLastDay() and
                 SecondsFromTime(OrMeanS) >= 0
              then 1
              else 0;
def ORHigh = if ORHigh[1] == 0
               or ORActive[1] == 0 and
                  ORActive == 1
               then h
               else if ORActive and
                       h > ORHigh[1]
               then h
               else ORHigh[1];
def ORLow = if ORLow[1] == 0
              or ORActive[1] == 0 and
                 ORActive == 1
              then l
              else if ORActive and
                      l < ORLow[1]
              then l
              else ORLow[1];
def ORWidth = ORHigh - ORLow;
def na = Double.NaN;
def ORHA = if ORActive
             or today < 1
             then na
             else ORHigh;
def ORLA = if ORActive
             or today < 1
             then na
             else ORLow;
def O = ORHA - Round(((ORHA - ORLA) / 2) / TickSize(), 0) * TickSize();
def ORActive2 = if SecondsTillTime(OrEnd) > 0 and
                     SecondsFromTime(OrBegin) >= 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(OrEnd) == 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);
plot ORLext = if BarNumber() >= HighestAll(ORmeanBar)
              then HighestAll(if IsNaN(c[-1])
                              then ORL[1]
                              else Double.NaN)
              else Double.NaN;
ORLext.SetDefaultColor(Color.YELLOW);
ORLext.SetStyle(Curve.LONG_DASH);
ORLext.SetLineWeight(3);
ORLext.HideTitle();
def ORH2 = if ORActive2
             or today < 1
             then na
             else ORHigh2;
plot ORH2ext = if BarNumber() >= HighestAll(ORendBar)
               then HighestAll(if IsNaN(c[-1])
                               then ORH2[1]
                               else Double.NaN)
               else Double.NaN;
ORH2ext.SetDefaultColor(Color.GREEN);
ORH2ext.SetStyle(Curve.LONG_DASH);
ORH2ext.SetLineWeight(3);
ORH2ext.HideTitle();
def ORL2 = if ORActive2
               or today < 1
             then na
             else ORLow2;
plot ORL2ext = if BarNumber() >= HighestAll(ORendBar)
               then HighestAll(if IsNaN(c[-1])
                               then ORL2[1]
                               else Double.NaN)
               else Double.NaN;
ORL2ext.SetDefaultColor(Color.RED);
ORL2ext.SetStyle(Curve.LONG_DASH);
ORL2ext.SetLineWeight(3);
ORL2ext.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;
plot d1 = If (TimeLine , ORH2, na);
plot d2 = If (TimeLine , ORH2 - ( pos * 2), na);
plot d3 = If (TimeLine , ORH2 - ( pos * 3), na);
plot d4 = If (TimeLine , ORH2 - ( pos * 4), na);
plot d5 = If (TimeLine , ORH2 - ( pos * 5), na);
plot d6 = If (TimeLine , ORH2 - ( pos * 6), na);
plot d7 = If (TimeLine , ORH2 - ( pos * 7), na);
plot d8 = If (TimeLine , ORH2 - ( pos * 8), na);
plot d9 = If (TimeLine , ORH2 - ( pos * 9), na);
plot d10 = If (TimeLine , (ORL2), na);
d1.SetPaintingStrategy(PaintingStrategy.POINTS);
d2.SetPaintingStrategy(PaintingStrategy.POINTS);
d3.SetPaintingStrategy(PaintingStrategy.POINTS);
d4.SetPaintingStrategy(PaintingStrategy.POINTS);
d5.SetPaintingStrategy(PaintingStrategy.POINTS);
d6.SetPaintingStrategy(PaintingStrategy.POINTS);
d7.SetPaintingStrategy(PaintingStrategy.POINTS);
d8.SetPaintingStrategy(PaintingStrategy.POINTS);
d9.SetPaintingStrategy(PaintingStrategy.POINTS);
d10.SetPaintingStrategy(PaintingStrategy.POINTS);
d1.AssignValueColor(GetColor(dColor));
d2.AssignValueColor(GetColor(dColor));
d3.AssignValueColor(GetColor(dColor));
d4.AssignValueColor(GetColor(dColor));
d5.AssignValueColor(GetColor(dColor));
d6.AssignValueColor(GetColor(dColor));
d7.AssignValueColor(GetColor(dColor));
d8.AssignValueColor(GetColor(dColor));
d9.AssignValueColor(GetColor(dColor));
d10.AssignValueColor(GetColor(dColor));
d1.HideBubble();
d2.HideBubble();
d3.HideBubble();
d4.HideBubble();
d5.HideBubble();
d6.HideBubble();
d7.HideBubble();
d8.HideBubble();
d9.HideBubble();
d10.HideBubble();
d1.HideTitle();
d2.HideTitle();
d3.HideTitle();
d4.HideTitle();
d5.HideTitle();
d6.HideTitle();
d7.HideTitle();
d8.HideTitle();
d9.HideTitle();
d10.HideTitle();
AddCloud(if CloudOn == yes
         then ORL
         else Double.NaN
       , ORL2, CreateColor(244, 83, 66), CreateColor(244, 83, 66));
AddCloud(if CloudOn == yes
         then ORL
         else Double.NaN
       , ORH2, CreateColor(66, 244, 131), CreateColor(66, 244, 131));
# Begin Risk Algorithm
# First Breakout or Breakdown bars
#bubbles
input bubblemover = 0;
def bm  = bubblemover;
def bm1 = bm + 1;
def BUBBLESPOT = showbubbles and IsNaN(close[bm]) && !IsNaN(close[bm1]);
def BreakoutBar = if ORActive
                    then Double.NaN
                    else if !ORActive and c crosses above ORH2
                         then bar
                         else if !IsNaN(BreakoutBar[1]) and c crosses ORH2
                              then BreakoutBar[1]
                    else BreakoutBar[1];
def ATR = if ORActive2
  then Round((Average(TrueRange(h, c, l), nAtr)) / TickSize(), 0) * TickSize()
  else ATR[1];
def cond1 =  if h > ORH2 and
                  h[1] <= ORH2
               then Round((ORH2  + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
               else cond1[1];
plot ORLriskUP = if bar >= ORendBar and !ORActive and today
                 then HighestAll(ORH2ext - 2)
                 else Double.NaN;
ORLriskUP.SetStyle(Curve.LONG_DASH);
ORLriskUP.SetDefaultColor(Color.GREEN);
ORLriskUP.HideTitle();
def crossUpBar = if close crosses above ORH2
                   then bar
                   else Double.NaN;
AddChartBubble(bar == HighestAll(crossUpBar), ORLriskUP, "RiskON ORH", Color.GREEN, no);
plot ORLriskDN = if bar >= ORendBar and !ORActive and close < ORL
                 then HighestAll(ORL2ext + 2)
                 else Double.NaN;
ORLriskDN.SetStyle(Curve.LONG_DASH);
ORLriskDN.SetDefaultColor(Color.RED);
ORLriskDN.HideTitle();
def crossDnBar = if close crosses below ORL2ext
                   then bar
                   else Double.NaN;
AddChartBubble(bar == HighestAll(crossDnBar), HighestAll(ORLriskDN), "Risk ON ORL", Color.RED, yes);
# High Targets
plot Htarget = if bar >= BreakoutBar
               then cond1
               else Double.NaN;
Htarget.SetPaintingStrategy(PaintingStrategy.SQUARES);
Htarget.SetLineWeight(1);
Htarget.SetDefaultColor(Color.WHITE);
Htarget.HideTitle();
AddChartBubble(BUBBLESPOT, Htarget[bm1], "RO", Color.WHITE, if c > Htarget then no else yes);
def condHtarget2 = if c crosses above cond1
  then Round((cond1 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget2[1];
plot Htarget2 = if bar >= BreakoutBar
                then  condHtarget2
                else Double.NaN;
Htarget2.SetPaintingStrategy(PaintingStrategy.SQUARES);
Htarget2.SetLineWeight(1);
Htarget2.SetDefaultColor(Color.PLUM);
Htarget2.HideTitle();
AddChartBubble(BUBBLESPOT, Htarget2[bm1], "2nd T", Color.PLUM, if c > Htarget2
                                                          then no
                                                          else yes);
def condHtarget3 = if c crosses above condHtarget2
  then Round((condHtarget2 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget3[1];
plot Htarget3 = if bar >= BreakoutBar
                then condHtarget3
                else Double.NaN;
Htarget3.SetPaintingStrategy(PaintingStrategy.SQUARES);
Htarget3.SetLineWeight(1);
Htarget3.SetDefaultColor(Color.PLUM);
Htarget3.HideTitle();
AddChartBubble(IsNaN(c[bm]), Htarget3[bm1], "3rd T", Color.PLUM, if c > Htarget3 then no else yes);
def condHtarget4 = if c crosses above condHtarget3
  then Round((condHtarget3 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget4[1];
plot Htarget4 = if bar >= HighestAll(BreakoutBar)
                then condHtarget4
                else Double.NaN;
Htarget4.SetPaintingStrategy(PaintingStrategy.SQUARES);
Htarget4.SetLineWeight(1);
Htarget4.SetDefaultColor(Color.PLUM);
Htarget4.HideTitle();
AddChartBubble(BUBBLESPOT, Htarget4[bm1], "4th T", Color.PLUM, if c > Htarget4 then no else yes);
def condHtarget5 = if c crosses above condHtarget4
  then Round((condHtarget4 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
  else condHtarget5[1];
plot Htarget5 = if bar >= BreakoutBar
                then condHtarget5
                else Double.NaN;
Htarget5.SetPaintingStrategy(PaintingStrategy.SQUARES);
Htarget5.SetLineWeight(1);
Htarget5.SetDefaultColor(Color.PLUM);
Htarget5.HideTitle();
AddChartBubble(BUBBLESPOT, Htarget5[bm1], "5th T", Color.PLUM, if c > Htarget5 then no else yes);
# Low Targets
def cond2 = if l < ORL2 and
                 l[1] >= ORL2
              then Round((ORL2  - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
              else cond2[1];
plot Ltarget =  if bar >= HighestAll(ORendBar)
                then HighestAll(if IsNaN(c[-1])
                                then cond2
                                else Double.NaN)
                else Double.NaN;
Ltarget.SetPaintingStrategy(PaintingStrategy.SQUARES);
Ltarget.SetLineWeight(1);
Ltarget.SetDefaultColor(Color.WHITE);
Ltarget.HideTitle();
AddChartBubble(BUBBLESPOT, cond2[bm1], "RO", Color.WHITE, if c < Ltarget
                                                     then yes
                                                     else no);
def condLtarget2 = if c crosses below cond2
  then Round((cond2 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget2[1];
plot Ltarget2 =  if bar >= HighestAll(ORendBar)
                 then HighestAll(if IsNaN(c[-1])
                                 then condLtarget2
                                 else Double.NaN)
                 else Double.NaN;
Ltarget2.SetPaintingStrategy(PaintingStrategy.SQUARES);
Ltarget2.SetLineWeight(1);
Ltarget2.SetDefaultColor(Color.PLUM);
Ltarget2.HideTitle();
AddChartBubble(BUBBLESPOT, condLtarget2[bm1], "2nd T", Color.PLUM, if c < condLtarget2
                                                              then yes
                                                              else no);
def condLtarget3 = if c crosses below condLtarget2
  then Round((condLtarget2 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget3[1];
plot Ltarget3 = if bar >= HighestAll(ORendBar)
                then HighestAll(if IsNaN(c[-1])
                                then condLtarget3
                                else Double.NaN)
                else Double.NaN;
Ltarget3.SetPaintingStrategy(PaintingStrategy.SQUARES);
Ltarget3.SetLineWeight(1);
Ltarget3.SetDefaultColor(Color.PLUM);
Ltarget3.HideTitle();
AddChartBubble(BUBBLESPOT, condLtarget3[bm1], "3rd T", Color.PLUM, if c < Ltarget3
                                                              then yes
                                                              else no);
def condLtarget4 = if c crosses condLtarget3
  then Round((condLtarget3 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget4[1];
plot Ltarget4 = if bar >= HighestAll(ORendBar)
                then HighestAll(if IsNaN(c[-1])
                                then condLtarget4
                                else Double.NaN)
                else Double.NaN;
Ltarget4.SetPaintingStrategy(PaintingStrategy.SQUARES);
Ltarget4.SetLineWeight(1);
Ltarget4.SetDefaultColor(Color.PLUM);
Ltarget4.HideTitle();
AddChartBubble(BUBBLESPOT, condLtarget4[bm1], "4th T", Color.PLUM, if c < Ltarget4
                                                              then yes
                                                              else no);
def condLtarget5 = if c crosses condLtarget4
  then Round((condLtarget4 - (AtrTargetMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget5[1];
plot Ltarget5 = if bar >= HighestAll(ORendBar)
                then HighestAll(if IsNaN(c[-1])
                                then condLtarget5
                                else Double.NaN)
                else Double.NaN;
Ltarget5.SetPaintingStrategy(PaintingStrategy.SQUARES);
Ltarget5.SetLineWeight(1);
Ltarget5.SetDefaultColor(Color.PLUM);
Ltarget5.HideTitle();
AddChartBubble(BUBBLESPOT, condLtarget5[bm1], "5th T", Color.PLUM, if c < Ltarget5
                                                              then yes
                                                              else no);
def last = if SecondsTillTime(1600) == 0 and
              SecondsFromTime(1600) == 0
           then c[1]
           else last[1];
plot LastClose = if today and last != 0
                 then last
                 else Double.NaN;
LastClose.SetPaintingStrategy(PaintingStrategy.DASHES);
LastClose.SetDefaultColor(Color.WHITE);
LastClose.HideBubble();
LastClose.HideTitle();
AddChartBubble(SecondsTillTime(0930) == 0, LastClose, "PC", Color.GRAY, yes);
Alert(c crosses above ORH2, "", Alert.BAR, Sound.Bell);
Alert(c crosses below ORL2, "", Alert.BAR, Sound.Ring);
#
 

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