Chart Bubble at Week High?

RedToGreen

Active member
This will show a chart bubble at the week high but for every bar.
How do I make it so it only shows 1 bubble?

I've looked thru other threads but simple stuff seems to evade me

Thanks

Code:
input aggregationPeriod = AggregationPeriod.WEEK;
input length = 1;
input displace = -1;
input showOnlyLastPeriod = no;

plot WeekH;
plot WeekL;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
    weekH = Double.NaN;
    WeekL = Double.NaN;
} else {
    WeekH = Highest(high(period = aggregationPeriod)[-displace], length);
    WeekL = Lowest(low(period = aggregationPeriod)[-displace], length);
}

WeekH.SetDefaultColor(createColor(35,78,135));
WeekH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
WeekL.SetDefaultColor(createColor(50,111,191));
WeekL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

addchartBubble( weekh, Highest(high(period = aggregationPeriod)[-displace], length), "WK_H", color.BLUE);
 
Last edited by a moderator:
I found this, which fixes my problem

Code:
AddChartBubble(!IsNaN(close) and IsNaN(close[-1]),weekh, Concat(“WK_H: “, weekh), Color.DARK_ORANGE, yes);

Now how do i display it on the left side
 
Here is your script with 3 bubble location options as described in the code below. Hope this helps
Code:
#Example_Bubble_Placement
#UseThinkscript request by RedtoGreen
#Modifications to Bubbles by Sleepy

input aggregationPeriod = AggregationPeriod.WEEK;
input length = 1;
input displace = 0;
input showOnlyLastPeriod = no;

plot WeekH;
plot WeekL;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
    WeekH = Double.NaN;
    WeekL = Double.NaN;
} else {
    WeekH = Highest(high(period = aggregationPeriod)[-displace], length);
    WeekL = Lowest(low(period = aggregationPeriod)[-displace], length);
}

WeekH.SetDefaultColor(CreateColor(35, 78, 135));
WeekH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
WeekL.SetDefaultColor(CreateColor(50, 111, 191));
WeekL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

#Defines the first time within each week where the '(high(period = aggregationPeriod) == high)'/ This limits bubbles to the one bubble each week at the highest high for week even though there may be multiple times that high was reached

def first = if
                if showonlyLastPeriod==yes
                then isnan(weekh[1]) and !isnan(weekh)
                else WeekH != WeekH[1]
            then 0
            else if (high(period = aggregationPeriod) == high)
            then 1
            else first[1] ;

#Method 1 - Places a bubble at the first time the high of week is reached
AddChartBubble(first[1] != 1 and first == 1,
               WeekH,
               Concat(“WK_H: “, WeekH), Color.DARK_ORANGE, yes);

#Method 2 - Places a bubble at the beginning of the week at the high of the week
AddChartBubble( if showonlyLastPeriod==yes then isnan(weekh[1]) and !isnan(weekh)
                else WeekH != WeekH[1],
                Highest(high(period = aggregationPeriod)[-displace], length),
                Concat(“WK_H: “, WeekH), Color.CYAN);

#Method 3 - Places a bubble at the end of the week at the high of the week
AddChartBubble( if showonlyLastPeriod==yes then isnan(close[-1]) and !isnan(close)
                else WeekH != WeekH[-1]
                or isnan(close[-1]) and !isnan(close),
                Highest(high(period = aggregationPeriod)[-displace], length),
                Concat(“WK_H: “, WeekH), Color.white);
Capture.jpg
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
363 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