Chart Bubble at Week High?

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
 

SleepyZ

Active member
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
 

Similar threads

Top