Adding price labels

MikelL

New member
I have this plotting lines

is there a way i can plot the price value of the line?
like if P32 is plotting a line at 3256.5 can i add a label that floats on the line saying 3256.5?

input sPeriod = AggregationPeriod.THIRTY_MIN;
input F32 = {default “yes”, “no”};
input F40 = {default “yes”, “no”};
input length = 14;
input averageType = AverageType.WEIGHTED;

def ATR = MovingAverage(averageType, TrueRange(high(period = sPeriod), close(period = sPeriod), low(period = sPeriod)), length);

def TWEN = ATR[1] * .32;
def TH1 = ATR[1] * .40;

def U32 = close(period = sPeriod)[1] + TWEN;
def U40 = close(period = sPeriod)[1] + TH1;


plot P32 = if !F32 then U32 else Double.NaN;
plot P40 = if !F40 then U40 else Double.NaN;
 

Pensar

Active member
VIP
@MikelL Try adding this to the bottom of your code, see if it is what you are looking for.

Code:
input show_bubbles = yes;
def current = !isnan(close) and isnan(close[-1]);
AddChartBubble(show_bubbles and current, P32, Round(P32), color.dark_orange, no);
AddChartBubble(show_bubbles and current, P40, Round(P40), color.light_green, yes);
 
Last edited:

jrob0124

New member
Hello,

Is it possible to show the price on a plotted line and not the bubble? For example, when using the price line drawing the price can be displayed on the left or the right of the line and is not used in a bubble, which looks very clean and easy to read. Can I do the same when I am using the plot function or another function?

plot Sup01 = Support01;Sup01.SetDefaultColor(Color.GRAY);Sup01.setStyle(Curve.LONG_DASH);Sup01.HideBubble()
 

Pensar

Active member
VIP
@jrob0124 As far as I know, plotting just the numerical value of a line is not possible without a bubble, perhaps someone with more experience can provide a better answer :). I did notice that in the sample of code you posted, there is HideBubble(). If you delete that line, you should see the current (most recent) value of the plot on the right/left axis (whichever you have it set to display on).

You can certainly move price bubbles to the far left of a chart; but I'm not certain what or where you're trying to plot. To move bubbles around, here is an sample from code I recently put together, it plots 50 bars back from the current bar.

Code:
def x = !isnan(close[-50]) and isnan(close[-51]);

There are many more ways to anchor bubbles on a chart, here is an excerpt from a ORB code by Mobius.

Code:
def bar = BarNumber();
def BubbleX = bar == HighestAll(bar);
AddChartBubble(BubbleX, RTHo, "RTH", Color.GRAY, 0);

And, here's a third way to anchor a bubble, this is from Mobius' Floor Trader Pivots study.

Code:
def Yesterday = GetDay() == GetLastDay() - 1;
def BubbleLocation = !yesterday and yesterday[1];
AddChartBubble(BubbleLocation, prevHigh, "Prev High", Color.DARK_GRAY, no);
 

Similar threads

Top