BubbleMover Code Snippet for ThinkOrSwim

SleepyZ

Moderator - Expert
VIP
Lifetime
This will allow you to move your bubbles sideways and/or up/down, but unfortunately TOS will not allow you to change the bubbles sideway's orientation. The following chart shows the moved bubbles in yellow Just change the inputs to move the bubbles to your liking.

04-08-2021-12-49-24-REC.png

Ruby:
def sellsignal = close crosses below Average(close, 20);

input bubblemoversideways = -1;
def b  = bubblemoversideways;
def b1 = b + 1;
input bubblemoverupdown   = 3;

AddChartBubble(sellsignal[b] and !IsNaN(close[b1]), high[b] + bubblemoverupdown * TickSize(), "Sell", Color.YELLOW, yes);
 
Last edited by a moderator:
Hi All,

I'd like to put the RR chart bubbles to the right of the current bar a few bars into the future. Is this possible to do? Currently the RR bubble on the current candle is hindering my view. If its not possible to push the bubbles to the right, am I able to eliminate the bubble on each current bar so that my view isn't hindered? I've searched existing studies but haven't been able to find the right code. Thanks in advance!


Code:
input marketThreshold = 0.0025;
input timeFrameDay = {default DAY};
input applyPersonsLevelsFilter = yes;

assert(marketThreshold >= 0, "'market threshold' must not be negative: " + marketThreshold);

def marketType = {default DISABLED, NEUTRAL, BEARISH, BULLISH};

def PP2 = high(period = timeFrameDay)[2] + low(period = timeFrameDay)[2] + close(period = timeFrameDay)[2];

marketType = if !applyPersonsLevelsFilter then marketType.DISABLED else
if PP2[-1] > (PP2[-1] + PP2 + PP2[1]) / 3 + marketThreshold then marketType.BULLISH else
if PP2[-1] < (PP2[-1] + PP2 + PP2[1]) / 3 - marketThreshold then marketType.BEARISH else marketType.NEUTRAL;

def R3;
def R2;
def R1;
def RR;
def PP;
def SS;
def S1;
def S2;
def S3;

if !IsNaN(close(period = timeFrameDay)[-1])
then {
    R1 = Double.NaN;
    R2 = Double.NaN;
    R3 = Double.NaN;
    PP = Double.NaN;
    S1 = Double.NaN;
    S2 = Double.NaN;
    S3 = Double.NaN;
} else {
    PP = (high(period = timeFrameDay)[1] + low(period = timeFrameDay)[1] + close(period = timeFrameDay)[1]) / 3;
    R1 = 2 * PP - low(period = timeFrameDay)[1];
    R2 = PP + high(period = timeFrameDay)[1] - low(period = timeFrameDay)[1];
    R3 = R2 + high(period = timeFrameDay)[1] - low(period = timeFrameDay)[1];
    S1 = 2 * PP - high(period = timeFrameDay)[1];
    S2 = PP - high(period = timeFrameDay)[1] + low(period = timeFrameDay)[1];
    S3 = S2 - high(period = timeFrameDay)[1] + low(period = timeFrameDay)[1];
}

RR = if (marketType == marketType.BEARISH or marketType == marketType.NEUTRAL) then R1 else R2;
SS = if (marketType == marketType.BULLISH or marketType == marketType.NEUTRAL) then S1 else S2;


def bn = HighestAll(if open == open then BarNumber()-3  else double.nan);
def futurebar = 5;
def x = (!IsNaN(close[futurebar]) and IsNaN(close[futurebar - 1]));


def RRBub = if barnumber() < bn then double.nan else  Highestall(if (isnan(close[-1]) and !IsNaN(close)) and RR > close * .99 and RR < close * 1.01 then 1 else double.nan);

DefineGlobalColor("D”, CreateColor(133, 163, 104));
addchartbubble(rrbub,RR, "RR", GlobalColor("D"));
 
Last edited:
Hi All,

I'd like to put the RR chart bubbles to the right of the current bar a few bars into the future. Is this possible to do? Currently the RR bubble on the current candle is hindering my view. If its not possible to push the bubbles to the right, am I able to eliminate the bubble on each current bar so that my view isn't hindered? I've searched existing studies but haven't been able to find the right code. Thanks in advance!


Code:
input marketThreshold = 0.0025;
input timeFrameDay = {default DAY};
input applyPersonsLevelsFilter = yes;

assert(marketThreshold >= 0, "'market threshold' must not be negative: " + marketThreshold);

def marketType = {default DISABLED, NEUTRAL, BEARISH, BULLISH};

def PP2 = high(period = timeFrameDay)[2] + low(period = timeFrameDay)[2] + close(period = timeFrameDay)[2];

marketType = if !applyPersonsLevelsFilter then marketType.DISABLED else
if PP2[-1] > (PP2[-1] + PP2 + PP2[1]) / 3 + marketThreshold then marketType.BULLISH else
if PP2[-1] < (PP2[-1] + PP2 + PP2[1]) / 3 - marketThreshold then marketType.BEARISH else marketType.NEUTRAL;

def R3;
def R2;
def R1;
def RR;
def PP;
def SS;
def S1;
def S2;
def S3;

if !IsNaN(close(period = timeFrameDay)[-1])
then {
    R1 = Double.NaN;
    R2 = Double.NaN;
    R3 = Double.NaN;
    PP = Double.NaN;
    S1 = Double.NaN;
    S2 = Double.NaN;
    S3 = Double.NaN;
} else {
    PP = (high(period = timeFrameDay)[1] + low(period = timeFrameDay)[1] + close(period = timeFrameDay)[1]) / 3;
    R1 = 2 * PP - low(period = timeFrameDay)[1];
    R2 = PP + high(period = timeFrameDay)[1] - low(period = timeFrameDay)[1];
    R3 = R2 + high(period = timeFrameDay)[1] - low(period = timeFrameDay)[1];
    S1 = 2 * PP - high(period = timeFrameDay)[1];
    S2 = PP - high(period = timeFrameDay)[1] + low(period = timeFrameDay)[1];
    S3 = S2 - high(period = timeFrameDay)[1] + low(period = timeFrameDay)[1];
}

RR = if (marketType == marketType.BEARISH or marketType == marketType.NEUTRAL) then R1 else R2;
SS = if (marketType == marketType.BULLISH or marketType == marketType.NEUTRAL) then S1 else S2;


def bn = HighestAll(if open == open then BarNumber()-3  else double.nan);
def futurebar = 5;
def x = (!IsNaN(close[futurebar]) and IsNaN(close[futurebar - 1]));


def RRBub = if barnumber() < bn then double.nan else  Highestall(if (isnan(close[-1]) and !IsNaN(close)) and RR > close * .99 and RR < close * 1.01 then 1 else double.nan);

DefineGlobalColor("D”, CreateColor(133, 163, 104));
addchartbubble(rrbub,RR, "RR", GlobalColor("D"));

This is a bubble mover code that should help by replacing your bubble code with the following. The input bubblemover will move the bubble sideways right/left (+/-) the number of bars/spaces input. This portion of the code (IsNaN(RRBub[b1]) and !IsNaN(RRBub) limits the bubbles to just one bubble.
Ruby:
input bubblemover = 5;
def b  = bubblemover;
def b1 = b + 1;

DefineGlobalColor("D”, CreateColor(133, 163, 104));
AddChartBubble(IsNaN(RRBub[b1]) and !IsNaN(RRBub[b]), RR[b], "RR", GlobalColor("D"));
 
How can you offset bubbles higher then the high of bar and lower then the low of bar so doesnt hide the candle ?

thank you for info, but im looking to offset the bubbles up and down, not sideways

can anyone give an example of format to add higher price to chart bubble please
 
How can you offset bubbles higher then the high of bar and lower then the low of bar so doesnt hide the candle ?

thank you for info, but im looking to offset the bubbles up and down, not sideways

can anyone give an example of format to add higher price to chart bubble please
Your question is how to define higher then the high of bar and lower then the low of bar for the location of the AddChartBubble so it doesn't hide the candle?

Answer:
You can add an offset to your location. IE: 1% higher then the high of bar or 1% lower then the low of bar
written as: low - (low*.01) or high + (high*.01)

So this script:
Rich (BB code):
AddChartBubble(Low, low-(low*.01), close, color.light_gray);
would produce this:
DqjfMfX.png
 
hi guys, i have an indicator that plot previous day's high/ low and overnight high/ low on the chart. its chart bubbles on these lines keep moving along with the current time.
so my problem is that when price goes close to one of these lines it is engulfed by the bubbles. so is there a way to move these bubbles to either a few bars to the left or right of the current bar? thanks
 
Last edited:
hi guys, i have an indicator that plot previous day's high/ low and overnight high/ low on the chart. its chart bubbles on these lines keep moving along with the current time.
so my problem is that when price goes close to one of these lines it is engulfed by the bubbles. so is there a way to move these bubbles to either a few bars to the left or right of the current bar? thanks

Without your code, here is an example that has a bubblemover input that you can use to move the bubbles left/right.

Capture.jpg
Ruby:
input time        = {default Day, Week, Month, Year};
input displace    = 1;
input bubblemover = 11;
def n  = bubblemover;
def n1 = n + 1;
input rthbegin = 0930;
input rthend   = 1600;
def pastOpen   = If((SecondsTillTime(rthbegin) > 0), 0, 1);
def pastClose  = If((SecondsTillTime(rthend) > 0), 0, 1);
def marketOpen = If(pastOpen and !pastClose, 1, 0);
def firstBar   = If (GetDay()[1] != GetDay(), GetDay() - 1, 0);
def h = high;
def l = low;
def o = open;
def c = close;
rec rthHigh = If(h > rthHigh[1] and marketOpen, h, If(marketOpen and !firstBar, rthHigh[1], h));
rec rthLow  = If(l < rthLow[1] and marketOpen, l, If(marketOpen and rthLow[1] > 0 and !firstBar, rthLow[1], l));

plot PH  = high(period = time)[displace];
plot PL  = low(period = time)[displace];
plot PC  = close(period = time)[displace];
plot TO  = open(period = time);
plot PP  = PivotPoints().pp;
plot HD  = if marketOpen then rthHigh else Double.NaN;
plot LD  = if marketOpen then rthLow  else Double.NaN;
plot MD  = (rthHigh + rthLow) / 2;
input showhlcloud = no;
AddCloud(if showhlcloud then  h + 10  else Double.NaN, HD, Color.DARK_GREEN);
AddCloud(if showhlcloud then LD else Double.NaN, l - 10  , Color.DARK_RED);

PH.SetDefaultColor(Color.GREEN);
PH.SetStyle(Curve.MEDIUM_DASH);
PH.SetLineWeight(2);
PH.HideBubble();

PL.SetDefaultColor(Color.RED);
PL.SetStyle(Curve.MEDIUM_DASH);
PL.SetLineWeight(2);
PL.HideBubble();

PC.SetDefaultColor(Color.YELLOW);
PC.SetStyle(Curve.LONG_DASH);
PC.SetLineWeight(2);
PC.HideBubble();

TO.SetDefaultColor(Color.WHITE);
TO.SetStyle(Curve.LONG_DASH);
TO.SetLineWeight(2);
TO.HideBubble();

PP.SetDefaultColor(Color.WHITE);
PP.SetStyle(Curve.SHORT_DASH);
PP.SetLineWeight(2);
PP.HideBubble();

HD.SetDefaultColor(Color.GREEN);
HD.SetStyle(Curve.SHORT_DASH);
HD.SetLineWeight(2);
HD.HideBubble();

LD.SetDefaultColor(Color.RED);
LD.SetStyle(Curve.SHORT_DASH);
LD.SetLineWeight(2);
LD.HideBubble();

MD.SetDefaultColor(Color.MAGENTA);
MD.SetStyle(Curve.POINTS);
MD.SetLineWeight(2);
MD.HideBubble();

input showbubbles = yes;
def StartPlot = if showbubbles == yes then (IsNaN(c[n]) and !IsNaN(c[n1])) else Double.NaN;

AddChartBubble(StartPlot,  Round(PH[n1], 2), "PH-" + Round(PH[n1], 2), Color.GREEN, yes);
AddChartBubble(StartPlot,  Round(PL[n1], 2), "PL-" + Round(PL[n1], 2), Color.RED, yes);
AddChartBubble(StartPlot,  Round(TO[n1], 2), "TO-" + Round(TO[n1], 2), Color.WHITE, yes);
AddChartBubble(StartPlot,  Round(PP[n1], 2), "PP-" + Round(PP[n1], 2), Color.WHITE, yes);
AddChartBubble(StartPlot,  Round(PC[n1], 2), "PC-" + Round(PC[n1], 2), Color.YELLOW, yes);
AddChartBubble(StartPlot,  Round(HD[n1], 2), "HD-" + Round(HD[n1], 2), Color.GREEN, yes);
AddChartBubble(StartPlot,  Round(LD[n1], 2), "LD-" + Round(LD[n1], 2), Color.RED, no);
AddChartBubble(StartPlot,  Round(MD[n1], 2), "MD-" + Round(MD[n1], 2), Color.MAGENTA, no);

def hdcloud   = if IsNaN(c)
                then hdcloud[1]
                else HD;
plot hdcloud1 = if !IsNaN(c)
                then Double.NaN
                else hdcloud;
def phcloud   = if IsNaN(c)
                then phcloud[1]
                else PH;
plot phcloudl = if !IsNaN(c[12])
                then Double.NaN
                else phcloud;
def plcloud   = if IsNaN(c)
                then plcloud[1]
                else PL;
plot plcloudl = if !IsNaN(c[12])
                then Double.NaN
                else plcloud;
def ldcloud   = if IsNaN(c)
                then ldcloud[1]
                else LD;
plot ldcloudl = if !IsNaN(c[12])
                then Double.NaN
                else ldcloud;
def pccloud   = if IsNaN(c)
                then pccloud[1]
                else PC;
plot pccloudl = if !IsNaN(c[12])
                then Double.NaN
                else pccloud;
AddCloud(hdcloud1, phcloudl, Color.GREEN, Color.GREEN);
AddCloud(phcloudl, pccloudl, Color.LIGHT_GREEN, Color.LIGHT_GREEN);
AddCloud(pccloudl, plcloudl, Color.LIGHT_RED, Color.LIGHT_RED);
AddCloud(plcloudl, ldcloudl, Color.RED, Color.RED);
 
  • Like
Reactions: bik
I'd like to have the RSI showed on the right side of the chart where the price is. I have the RSI as bubble on top of the last candle but it blocks some view. THanks.
 
I'd like to have the RSI showed on the right side of the chart where the price is. I have the RSI as bubble on top of the last candle but it blocks some view. THanks.

You can move the bubble in this code sideways to where you want it.

Ruby:
#
# TD Ameritrade IP Company, Inc. (c) 2007-2022
#

declare lower;

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);
plot OverSold = over_Sold;
plot OverBought = over_Bought;
plot UpSignal = if RSI crosses above OverSold then OverSold else Double.NaN;
plot DownSignal = if RSI crosses below OverBought then OverBought else Double.NaN;

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

RSI.DefineColor("OverBought", GetColor(5));
RSI.DefineColor("Normal", GetColor(7));
RSI.DefineColor("OverSold", GetColor(1));
RSI.AssignValueColor(if RSI > over_Bought then RSI.Color("OverBought") else if RSI < over_Sold then RSI.Color("OverSold") else RSI.Color("Normal"));
OverSold.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(8));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

#Bubble
input showbubble  = yes;
input bubblemover = 3;
def bm  = bubblemover;
def bm1 = bm + 1;
addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), rsi[bm1],
               rsi[bm1], color.white);
 
You can move the bubble in this code sideways to where you want it.
Hi,
This is the code and have and it works:

plot rsi = reference RSI (14);



AddChartBubble(!IsNaN(close) and IsNaN(close [-1] ) , close , Round (rsi, 1) + "" , Color.WHITE);

However the bubble disappears when replacing the above AddChartBubble with ;

input showbubble = yes;
input bubblemover = 3;
def bm = bubblemover;
def bm1 = bm + 1;
addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), rsi[bm1],
rsi[bm1], color.white);

Thanks.
 
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]
 
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!
 
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
338 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