Only display on current candle

FateOwnzYou

Active member
VIP
VIP Enthusiast
I am trying to make a certain number only display on the current candle but having difficulty coming up with a condition for it. I dont want this number to show on every candle in the past, only on the current. I just need a condition that would be true on the current candle, but none of the past, anyone have a quick condition in back of their head that I cannot think of?
 
Solution
@FateOwnzYou Sorry, I didn't want to step on @BenTen's convo w/you. I love this snippet of code:

Add A Chart Bubble TO Current Candle:

Java:
addchartBubble(isnan(close[-1]), text = close, "price location" = HIGH, color = Color.ORANGE);

FateOwnzYou

Active member
VIP
VIP Enthusiast
Just really need a condition of anything, any certain code. But ya, I need the latest number to be displayed on ONLY the current bar of this script

Code:
def SetUpCount = CompoundValue(1, if close > close[4]
                 then SetUpCount[1] + 1
                 else if close < close[4]
                 then 0
                 else SetUpCount[1], 1);

plot Count = setupcount;
     count.SetPaintingStrategy(PaintingStrategy.Values_Above);
     Count.Setdefaultcolor(color.cyan);

So in the "plot" i need to make it a condition instead of just declaring "setupcount", I have tried

plot Count = if !setupcount[-1] then setupcount else double.nan

which would be checking if a value was there before that candle even formed and if there was no value, then it should plot it on the latest candle, but apparently there is a value on a futures candle that hasnt formed yet, which is odd
 

halcyonguy

New member
i would like to expand on that solution and offer another.
the reason this works , is that there are no candles with a high value, after the last bar. so 'price location' has an error after the last candle and causes addchartbubble() not to be drawn.
Code:
addchartBubble(isnan(close[-1]), text = close, "price location" = HIGH, color = Color.ORANGE);

after the last candle, there are placeholders for undrawn candles.
if constants are used in the bubble function, multiple bubbles will be drawn after the last candle.
Code:
addchartBubble(isnan(close[-1]), 80, "zzz", Color.ORANGE, yes);

here is an alternative code, that is true on the last candle. it checks if the current candle close is valid and if the next one is an error.
Code:
addchartBubble(!isnan(close[0]) and isnan(close[-1]), high, close, Color.ORANGE, yes);

from that code, you can add a constant, to pick a candle, that is x candles before or after the last one.
Code:
# plots a bubble x bars after last bar
input bars_in_future = 3;
def bif = bars_in_future;
def cls = close;
def x = isNaN(cls[bif]) and !isNaN(cls[bif+1]);
def vert = cls[bif+1];
AddChartBubble(x, vert, vert, color.white, yes);

kCsoRK9.png
 
Last edited:

KG3344

New member
VIP
Hello everyone,

I was wondering if anyone knew how to hide a plot past the current day. I have a script I have been playing with but it draws the plot out to the right edge of the chart, and it would make it easier to read if the line plot just ended at the current bar on a daily chart.

Thanks so much!
 

Similar threads

Top