Plot 52-week high/low once using current symbol

Advancing

Advancing

New member
VIP
Hello,
Looking to plot 52 week high and 52 week low once and not dynamically update (recalculate) with each tick.

Code:
def Start;
def Finish;

if (GetUnderlyingSymbol() == GetSymbol())
{
    Start = Highest(high, 252);
    Finish = Lowest(low, 252);
}
else
{
    Start = Double.NaN;
    Finish = Double.NaN;
}
 
N

Nikola

New member
Using this to show a dashed line for 52wk high, how can i add a price bubble to show on the right axis

Code:
def a = Highest(high, 252);
def barNumber = barNumber();
def bar = if IsNaN(a)
then Double.NaN
else BarNumber();
def ThisBar = HighestAll(bar);
def Line = if bar == ThisBar
then a
else Double.NaN;
plot P = if ThisBar
then HighestAll(Line)
else Double.NaN;
P.SetStyle(Curve.Short_Dash);
P.SetLineWeight(1);
P.SetDefaultColor(CreateColor(75,250,150));
 
BenTen

BenTen

Administrative
Staff
VIP
@Nikola Add the following snippet to the bottom of your script:

Code:
input showBubble = yes;
def SR = showBubble and !IsNaN(close) and IsNaN(close [-1] ) && HighestAll(BarNumber());
AddChartBubble(SR and p, HighestAll(Line), "Highest", Color.RED, yes);
 
BenTen

BenTen

Administrative
Staff
VIP
@Nikola Here you go:

Code:
def a = Lowest(low, 252);
def barNumber = barNumber();
def bar = if IsNaN(a)
then Double.NaN
else BarNumber();
def ThisBar = HighestAll(bar);
def Line = if bar == ThisBar
then a
else Double.NaN;
plot P = if ThisBar
then HighestAll(Line)
else Double.NaN;
P.SetStyle(Curve.Short_Dash);
P.SetLineWeight(1);
P.SetDefaultColor(CreateColor(75,250,150));

input showBubble = yes;
def SR = showBubble and !IsNaN(close) and IsNaN(close [-1] ) && HighestAll(BarNumber());
AddChartBubble(SR and a, HighestAll(Line), "Lowest", Color.Green, yes);
 
N

Nikola

New member
It wont work in the same script because the "def a" and "plot p".

Can the bubbles be moved to the left so they don't block stuff?
 
Last edited by a moderator:
BenTen

BenTen

Administrative
Staff
VIP
@Nikola Just create two scripts. Not sure about moving the bubbles to the left.
 

Similar threads

Top