Chart bubble Movement with the TICKOFFSET.

Solution
Is it possible to get a chart bubble at the top of the box, which moves with the "Tickoffset" extension as per post

https://usethinkscript.com/threads/...on-on-futures-intraday-charts.2087/post-58481

I added the following bubble code to the script you referenced. It has an option to display bubbles and limit bubbles. I included some data and coloring to the bubbles that you can modify to your liking.

Capture.jpg
Ruby:
# Example Using Addchart to draw a 'Box' around each candle meeting a condition. The 'box' can be extended by the number of ticks entered at the input, tickoffset

# Sleepyz

input tickoffset = 5;
input charttype  = ChartType.CANDLE;
def o = open;
def h = high;
def l = low...
Is it possible to get a chart bubble at the top of the box, which moves with the "Tickoffset" extension as per post

https://usethinkscript.com/threads/...on-on-futures-intraday-charts.2087/post-58481

I added the following bubble code to the script you referenced. It has an option to display bubbles and limit bubbles. I included some data and coloring to the bubbles that you can modify to your liking.

Capture.jpg
Ruby:
# Example Using Addchart to draw a 'Box' around each candle meeting a condition. The 'box' can be extended by the number of ticks entered at the input, tickoffset

# Sleepyz

input tickoffset = 5;
input charttype  = ChartType.CANDLE;
def o = open;
def h = high;
def l = low;
def c = close;
def nan = Double.NaN;

def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
def PatternPlot =
    if ((Sum(IsUp, 1)[3] >= 0)) and
    ((Sum(IsUp, 1)[2] >= 0)) and
    ((Sum(IsUp, 1)[1] >= 0)) and
    ((Sum(IsUp, 1)[0] >= 0)) and
    Highest(high[3], 1) < Highest(high[2], 1) and
    Highest(high[2], 1) < Highest(high[1], 1) and
    Highest(high[1], 1) < Highest(high[0], 1) then 1 else 0;
def cancelPatternPlot = if PatternPlot[1] == 1 then 1 else 0;

def condition = PatternPlot == 1 and cancelPatternPlot == 0;

def o1 = if condition then h + TickSize() * tickoffset else nan;
def c1 = if condition then l - TickSize() * tickoffset else nan;
def h1 = if condition then h + TickSize() * tickoffset else nan;
def l1 = if condition then l - TickSize() * tickoffset else nan;

DefineGlobalColor(color = Color.YELLOW, name = "Box");
input usepricecolor = yes;
AssignPriceColor(if usepricecolor and condition then GlobalColor("Box") else Color.CURRENT);
AddChart(growcolor = GlobalColor("Box"), high = h1, low = l1, open = c1, close = o1, type = charttype);

#Bubbles
input showbubble     = yes;
input limitbubbles   = yes;
input show_x_bubbles = 3;
def Count = CompoundValue(1, if condition
                             then Count[1] + 1
                             else Count[1], 0);
def this  = (HighestAll(Count) - Count) + 1;

AddChartBubble(showbubble and
               if limitbubbles
               then this <= show_x_bubbles and
                    condition
               else condition,
               h1,
               "H: " + high + "\nO: " + open + "\nC: " + close + "\nL: " + low,
               if close > open
               then Color.GREEN
               else Color.RED);
 
Solution

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

I added the following bubble code to the script you referenced. It has an option to display bubbles and limit bubbles. I included some data and coloring to the bubbles that you can modify to your liking.
I absolutely love this code. Can the code be flipped? that is the 3rd candle down with a lower bubble? I use it on Forex charts and it helps a lot!
 
I absolutely love this code. Can the code be flipped? that is the 3rd candle down with a lower bubble? I use it on Forex charts and it helps a lot!

See if this is what you requested. The flipped code will be magenta "Boxes" and lower bubbles.

Ruby:
# Example Using Addchart to draw a 'Box' around each candle meeting a condition. The 'box' can be extended by the number of ticks entered at the input, tickoffset

# Sleepyz

input tickoffset = 5;
input charttype  = ChartType.CANDLE;
def o = open;
def h = high;
def l = low;
def c = close;
def nan = Double.NaN;

def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
def PatternPlot =
    if ((Sum(IsUp, 1)[3] >= 0)) and
    ((Sum(IsUp, 1)[2] >= 0)) and
    ((Sum(IsUp, 1)[1] >= 0)) and
    ((Sum(IsUp, 1)[0] >= 0)) and
    Highest(high[3], 1) < Highest(high[2], 1) and
    Highest(high[2], 1) < Highest(high[1], 1) and
    Highest(high[1], 1) < Highest(high[0], 1) then 1 else 0;
def cancelPatternPlot = if PatternPlot[1] == 1 then 1 else 0;

def condition = PatternPlot == 1 and cancelPatternPlot == 0;

def o1 = if condition then h + TickSize() * tickoffset else nan;
def c1 = if condition then l - TickSize() * tickoffset else nan;
def h1 = if condition then h + TickSize() * tickoffset else nan;
def l1 = if condition then l - TickSize() * tickoffset else nan;

DefineGlobalColor(color = Color.YELLOW, name = "BoxH");
input usepricecolor = yes;
AssignPriceColor(if usepricecolor and condition then GlobalColor("BoxH") else Color.CURRENT);
AddChart(growcolor = GlobalColor("BoxH"), high = h1, low = l1, open = c1, close = o1, type = charttype);

def PatternPlot1 =
    if ((Sum(IsDown, 1)[3] >= 0)) and
    ((Sum(IsDown, 1)[2] >= 0)) and
    ((Sum(IsDown, 1)[1] >= 0)) and
    ((Sum(IsDown, 1)[0] >= 0)) and
    Lowest(low[3], 1) > Lowest(low[2], 1) and
    Lowest(low[2], 1) > Lowest(low[1], 1) and
    Lowest(low[1], 1) > Lowest(low[0], 1) then 1 else 0;
def cancelPatternPlot1 = if PatternPlot1[1] == 1 then 1 else 0;

def condition1 = PatternPlot1 == 1 and cancelPatternPlot1 == 0;

def o2 = if condition1 then h + TickSize() * tickoffset else nan;
def c2 = if condition1 then l - TickSize() * tickoffset else nan;
def h2 = if condition1 then h + TickSize() * tickoffset else nan;
def l2 = if condition1 then l - TickSize() * tickoffset else nan;

DefineGlobalColor(color = Color.MAGENTA, name = "BoxL");
AssignPriceColor(if usepricecolor and condition1 then GlobalColor("BoxL") else Color.CURRENT);
AddChart(growcolor = GlobalColor("BoxL"), high = h2, low = l2, open = c2, close = o2, type = charttype);


#Bubbles
input showbubble     = yes;
input limitbubbles   = yes;
input show_x_bubbles = 3;
def Count = CompoundValue(1, if condition
                             then Count[1] + 1
                             else Count[1], 0);
def this  = (HighestAll(Count) - Count) + 1;

AddChartBubble(showbubble and
               if limitbubbles
               then this <= show_x_bubbles and
                    condition
               else condition,
               h1,
               "H: " + high + "\nO: " + open + "\nC: " + close + "\nL: " + low,
               if close > open
               then Color.GREEN
               else Color.RED);

def Count1 = CompoundValue(1, if condition1
                             then Count1[1] + 1
                             else Count1[1], 0);
def this1  = (HighestAll(Count1) - Count1) + 1;

AddChartBubble(showbubble and
               if limitbubbles
               then this1 <= show_x_bubbles and
                    condition1
               else condition1,
               l2,
               "H: " + high + "\nO: " + open + "\nC: " + close + "\nL: " + low,
               if close > open
               then Color.GREEN
               else Color.RED, no);
#
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
391 Online
Create Post

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