Plot range of first 15min

N

Nikola

New member
I am using this code that plots the PM high/lows, it works awesome on mobile. I would like to however show the range for the first 15min of the trading day (not PM). I tried the ORB codes but they wont show up on mobile.

15min low - red line
15min high - green line

Code:
# OvernightHiLowLines_mobius_jq
# GlobeX or Overnight High / Low without Fibonacci Values
# Based on code by Mobius # V01.2012
# cosmetic alterations by Johnny Quotron
#    1. removal of fib lines
#    2. paint ONL bubble below the line
#    3. addition of other comments
#    4. addition of bubbles in the expansion area if desired
#
# Restrictions:  Hi / Low lines are not drawn for non-traded indicies such as VIX or TNX..JQ

declare hide_on_daily;
input PlotOverNightExtremes = yes;
input DisplayPriceBubbleOnHiLowBar = yes;
input DisplayPriceBubbleOnRightEdge = yes;  #Haven't figured this out yet..JQ

def o = open;
def h = high;
def l = low;
def c = close;
def v = volume;
def bar = BarNumber();
def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());

def vol = if GlobeX and !GlobeX[1]
then v
else if GlobeX
then vol[1] + v
else Double.NaN;

def GlobeX_Volume = vol;

def ONhigh = if GlobeX and !GlobeX[1]
then h
else if GlobeX and
h > ONhigh[1]
then h
else ONhigh[1];

def ONhighBar = if GlobeX and h == ONhigh
then bar
else Double.NaN;

def ONlow = if GlobeX and !GlobeX[1]
then l
else if GlobeX and
l < ONlow[1]
then l
else ONlow[1];

def ONlowBar = if GlobeX and l == ONlow
then bar
else Double.NaN;

def OverNightHigh = if BarNumber() == HighestAll(ONhighBar)
then ONhigh
else OverNightHigh[1];

def OverNightLow = if BarNumber() == HighestAll(ONlowBar)
then ONlow
else OverNightLow[1];


#
plot ONH = if OverNightHigh > 0
then OverNightHigh
else Double.NaN;

ONH.SetHiding(!PlotOverNightExtremes);
ONH.SetPaintingStrategy(PaintingStrategy.SQUARES);
ONH.SetDefaultColor(Color.BLUE);
ONH.HideBubble();
ONH.HideTitle();

#
plot ONL = if OverNightLow > 0
then OverNightLow
else Double.NaN;

ONL.SetHiding(!PlotOverNightExtremes);
ONL.SetPaintingStrategy(PaintingStrategy.SQUARES);
ONL.SetDefaultColor(Color.LIGHT_GRAY);
ONL.HideBubble();
ONL.HideTitle();


# Bubble code
AddChartBubble(bar == ONhighBar and PlotOverNightExtremes and DisplayPriceBubbleOnHiLowBar, ONH, "ONH: " + ONH, createColor(204,204,255));
AddChartBubble(bar == ONlowBar and PlotOverNightExtremes and DisplayPriceBubbleOnHiLowBar, ONL, "ONL: " + ONL, createColor(204,204,255),no);  #designated that the bubble be painted below the ONL line.  2018-04-07 JQ


AddChartBubble(barNumber() == highestAll(barnumber()) and  PlotOverNightExtremes and DisplayPriceBubbleOnRightEdge, ONH, "ONH: " + ONH, createColor(204,204,255));
AddChartBubble(barNumber() == highestAll(barnumber()) and PlotOverNightExtremes and DisplayPriceBubbleOnRightEdge, ONL, "ONL: " + ONL, createColor(204,204,255),no);
# End Code GlobeX or Overnight High / Low without Fibonacci Values
 
Last edited by a moderator:
V

VicD

Member
Opening range lines, you can turn on and off lines and also change the 5min to 15


Code:
#hint: Investheory LLC https://investheory.com
#hint period: If you don't want the developing range to look jagged, choose a larger timeframe than the chart (but shorter than or equal to the opening range time window) at which the opening range becomes fixed. For instance, if you have a 30' opening range on a 1' chart and you don't want the OR high/low lines moving every single minute, set the timeframe to 15' or 30' so it will only update twice or once during the OR formation.
#hint orStartTime: Choose the time at which the OR begins forming, in HHMM 24 hour format and in the Eastern time zone. 0930 means 9:30 A.M.
#hint orEndTime: Choose the time at which the OR ends forming, in HHMM 24 hour format and in the Eastern time zone. 1600 means 4:00 P.M. Default setting is 1000.
#hint showOnlyToday: Hide lines on prior days.
#hint showCloud: Paint a cloud in the background during the opening range formation.
#hint showMidpoint: Show a line in the middle of the opening range.
#hint showQuarters: Show lines for 75% and 25% of the opening range, on either side of the midpoint.
#hint showTargets: Plot targets at defined multiples of the opening range width.
#hint useTradeSignals: Turn up/down arrows on or off.
#hint useAlerts: Turn all the alerts on or off with one setting.
#hint multiplier1: Choose the multiple of the OR width that you will use for first target. 1.5 = 150% of the opening range.
#hint multiplier2: Choose the multiple of the OR width that you will use for second target. 1.5 = 150% of the opening range.
#hint multiplier3: Choose the multiple of the OR width that you will use for third target. 1.5 = 150% of the opening range.

# inputs
input orStartTime = 0930;
input orEndTime = 1000;
input period = aggregationPeriod.THIRTY_MIN;
input showOnlyToday = yes;
input showCloud = yes;
input showMidpoint = yes;
input showQuarters = yes;
input useTradeSignals = yes;
input useAlerts = yes;
input showTargets = yes;
input multiplier1 = 0.5;
input multiplier2 = 1.0;
input multiplier3 = 1.5;

# constants
def na = double.nan;
def hi = high(period = period);
def lo = low(period = period);
defineGlobalColor("Cloud", color.gray);

# opening range time logic
def isOr = secondstilltime(orEndTime) > 0
    and secondsfromtime(orStartTime) >= 0;
def today = (!showOnlyToday or getday() == getlastday())
    and secondsfromtime(orStartTime) >= 0 and !isNAN(close);

# opening range levels logic
rec orhi =
    if orhi[1] == 0
        or !isOr[1]
        and isOr
    then hi
    else if isOr
        and hi > orhi[1]
    then hi
    else orhi[1];

rec orlo =
    if orlo[1] == 0
        or !isOr[1]
        and isOr
    then lo
    else if isOr
        and lo < orlo[1]
    then lo
    else orlo[1];

# plots
plot orh = if today < 1 then na else orhi;
plot orl = if today < 1 then na else orlo;
plot orm = if !isOr then (orh + orl) / 2 else na;
plot orqh = if !isOr then (orh + orm) / 2 else na;
plot orql = if !isOr then (orl + orm) / 2 else na;

orm.setHiding(!showMidpoint);
orqh.setHiding(!showQuarters);
orql.setHiding(!showQuarters);

def range = orhi - orlo;

plot u1 = if showTargets and !isOr then orh + range * multiplier1 else na;
plot u2 = if showTargets and !isOr then orh + range * multiplier2 else na;
plot u3 = if showTargets and !isOr then orh + range * multiplier3 else na;

plot l1 = if showTargets and !isOr then orl - range * multiplier1 else na;
plot l2 = if showTargets and !isOr then orl - range * multiplier2 else na;
plot l3 = if showTargets and !isOr then orl - range * multiplier3 else na;

plot highBreak = useTradeSignals and !isOr and close crosses above orh;
plot lowBreak = useTradeSignals and !isOr and close crosses below orl;

plot midhighbreak = useTradeSignals and !isOr and close crosses above orm;
plot midlowbreak = useTradeSignals and !isOr and close crosses below orm;

plot highQBreak = useTradeSignals and !isOr and close crosses above orqh;
plot lowQBreak = useTradeSignals and !isOr and close crosses below orql;

plot longTarget1 = useTradeSignals and !isOr and close crosses above u1;
plot longTarget2 = useTradeSignals and !isOr and close crosses above u2;
plot longTarget3 = useTradeSignals and !isOr and close crosses above u3;

plot shortTarget1 = useTradeSignals and !isOr and close crosses below l1;
plot shortTarget2 = useTradeSignals and !isOr and close crosses below l2;
plot shortTarget3 = useTradeSignals and !isOr and close crosses below l3;

addcloud(if showcloud and isOR then orh else na, if showcloud and isOR then orl else na, color1 = globalColor("Cloud"));

# look and feel
orh.setPaintingStrategy(paintingStrategy.HORIZONTAL);
orl.setPaintingStrategy(paintingStrategy.HORIZONTAL);
orm.setPaintingStrategy(paintingStrategy.HORIZONTAL);
orqh.setPaintingStrategy(paintingStrategy.HORIZONTAL);
orql.setPaintingStrategy(paintingStrategy.HORIZONTAL);
orh.setdefaultcolor(color.gray);
orl.setdefaultcolor(color.gray);
orm.setdefaultcolor(color.dark_gray);
orqh.setdefaultcolor(color.light_gray);
orql.setdefaultcolor(color.light_gray);

u1.setPaintingStrategy(paintingStrategy.HORIZONTAL);
u2.setPaintingStrategy(paintingStrategy.HORIZONTAL);
u3.setPaintingStrategy(paintingStrategy.HORIZONTAL);

l1.setPaintingStrategy(paintingStrategy.HORIZONTAL);
l2.setPaintingStrategy(paintingStrategy.HORIZONTAL);
l3.setPaintingStrategy(paintingStrategy.HORIZONTAL);

u1.setdefaultcolor(color.dark_green);
u2.setdefaultcolor(color.light_green);
u3.setdefaultcolor(color.green);

l1.setdefaultcolor(color.dark_red);
l2.setdefaultcolor(color.light_red);
l3.setdefaultcolor(color.red);

highBreak.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
lowbreak.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_DOWN);
midHighBreak.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
midLowBreak.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_DOWN);
highQBreak.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
lowQBreak.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_DOWN);

highBreak.setdefaultcolor(color.dark_green);
lowbreak.setdefaultcolor(color.dark_red);
midHighBreak.setdefaultcolor(color.dark_green);
midLowBreak.setdefaultcolor(color.dark_red);
highQBreak.setdefaultcolor(color.dark_green);
lowQBreak.setdefaultcolor(color.dark_red);

longTarget1.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_DOWN);
longTarget2.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_DOWN);
longTarget3.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_DOWN);

shortTarget1.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
shortTarget2.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
shortTarget3.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);

longTarget1.setdefaultcolor(color.dark_red);
longTarget2.setdefaultcolor(color.dark_red);
longTarget3.setdefaultcolor(color.dark_red);

shortTarget1.setdefaultcolor(color.dark_green);
shortTarget2.setdefaultcolor(color.dark_green);
shortTarget3.setdefaultcolor(color.dark_green);

alert(useAlerts and highBreak, "ORH Breakout", "alert type" = Alert.BAR, sound = Sound.Ding);
alert(useAlerts and lowBreak, "ORL Breakdown", "alert type" = Alert.BAR, sound = Sound.Ding);
alert(useAlerts and midhighBreak, "ORM Breakout", "alert type" = Alert.BAR, sound = Sound.Ding);
alert(useAlerts and midlowBreak, "ORM Breakdown", "alert type" = Alert.BAR, sound = Sound.Ding);
alert(useAlerts and highqBreak, "ORQ Breakout", "alert type" = Alert.BAR, sound = Sound.Ding);
alert(useAlerts and lowqBreak, "ORQ Breakdown", "alert type" = Alert.BAR, sound = Sound.Ding);

alert(useAlerts and longTarget1, "Breakout Target 1", "alert type" = Alert.BAR, sound = Sound.Ding);
alert(useAlerts and longTarget2, "Breakout Target 2", "alert type" = Alert.BAR, sound = Sound.Ding);
alert(useAlerts and longTarget3, "Breakout Target 3", "alert type" = Alert.BAR, sound = Sound.Ding);

alert(useAlerts and shortTarget1, "Breakdown Target 1", "alert type" = Alert.BAR, sound = Sound.Ding);
alert(useAlerts and shortTarget2, "Breakdown Target 2", "alert type" = Alert.BAR, sound = Sound.Ding);
alert(useAlerts and shortTarget3, "Breakdown Target 3", "alert type" = Alert.BAR, sound = Sound.Ding);
 
V

VicD

Member
same but opening range fib extensions

Code:
# inputs
input orStartTime = 0930;
input orEndTime = 1000;
input period = aggregationPeriod.THIRTY_MIN;
input showOnlyToday = yes;
input showCloud = yes;
input showMidpoint = yes;
input showQuarters = yes;
input useTradeSignals = yes;
input useAlerts = yes;
input showTargets = yes;
input fibext1 = .272;
input fibext2 = .618;
input fibext3 = 1.618;
input fibext4 = 2.618;

# constants
def na = double.nan;
def hi = high(period = period);
def lo = low(period = period);
defineGlobalColor("Cloud", color.gray);

# opening range time logic
def isOr = secondstilltime(orEndTime) > 0
    and secondsfromtime(orStartTime) >= 0;
def today = (!showOnlyToday or getday() == getlastday())
    and secondsfromtime(orStartTime) >= 0 and !isNAN(close);

# opening range levels logic
rec OR100 =
    if OR100[1] == 0
        or !isOr[1]
        and isOr
    then hi
    else if isOr
        and hi > OR100[1]
    then hi
    else OR100[1];

rec OR0 =
    if OR0[1] == 0
        or !isOr[1]
        and isOr
    then lo
    else if isOr
        and lo < OR0[1]
    then lo
    else OR0[1];

# plots
plot orh = if today < 1 then na else OR100;
plot orl = if today < 1 then na else OR0;
plot orm = if !isOr then (orh + orl) / 2 else na;
plot fib618 = if !isOr then (orl + (orh - orl) * .61803398875) else na;
plot fib382 = if !isOr then (orl + (orh - orl) * .38196601125) else na;
orm.setHiding(!showMidpoint);
fib618.setHiding(!showQuarters);
fib382.setHiding(!showQuarters);

def range = OR100 - OR0;

plot u1 = if showTargets and !isOr then orh + range * fibext1 else na;
plot u2 = if showTargets and !isOr then orh + range * fibext2 else na;
plot u3 = if showTargets and !isOr then orh + range * fibext3 else na;
plot u4 = if showTargets and !isOr then orh + range * fibext4 else na;

plot l1 = if showTargets and !isOr then orl - range * fibext1 else na;
plot l2 = if showTargets and !isOr then orl - range * fibext2 else na;
plot l3 = if showTargets and !isOr then orl - range * fibext3 else na;
plot l4 = if showTargets and !isOr then orl - range * fibext4 else na;

plot highBreak = useTradeSignals and !isOr and close crosses above orh;
plot lowBreak = useTradeSignals and !isOr and close crosses below orl;

plot midhighbreak = useTradeSignals and !isOr and close crosses above orm;
plot midlowbreak = useTradeSignals and !isOr and close crosses below orm;

plot highQBreak = useTradeSignals and !isOr and close crosses above fib618;
plot lowQBreak = useTradeSignals and !isOr and close crosses below fib382;

plot longTarget1 = useTradeSignals and !isOr and close crosses above u1;
plot longTarget2 = useTradeSignals and !isOr and close crosses above u2;
plot longTarget3 = useTradeSignals and !isOr and close crosses above u3;
plot longTarget4 = useTradeSignals and !isOr and close crosses above u4;

plot shortTarget1 = useTradeSignals and !isOr and close crosses below l1;
plot shortTarget2 = useTradeSignals and !isOr and close crosses below l2;
plot shortTarget3 = useTradeSignals and !isOr and close crosses below l3;
plot shortTarget4 = useTradeSignals and !isOr and close crosses below l4;

addcloud(if showcloud and isOR then orh else na, if showcloud and isOR then orl else na, color1 = globalColor("Cloud"));

# look and feel
orh.setPaintingStrategy(paintingStrategy.HORIZONTAL);
orl.setPaintingStrategy(paintingStrategy.HORIZONTAL);
orm.setPaintingStrategy(paintingStrategy.HORIZONTAL);
fib618.setPaintingStrategy(paintingStrategy.HORIZONTAL);
fib382.setPaintingStrategy(paintingStrategy.HORIZONTAL);
orh.setdefaultcolor(color.gray);
orl.setdefaultcolor(color.gray);
orm.setdefaultcolor(color.dark_gray);
fib618.setdefaultcolor(color.light_gray);
fib382.setdefaultcolor(color.light_gray);

u1.setPaintingStrategy(paintingStrategy.HORIZONTAL);
u2.setPaintingStrategy(paintingStrategy.HORIZONTAL);
u3.setPaintingStrategy(paintingStrategy.HORIZONTAL);
u4.setPaintingStrategy(paintingStrategy.HORIZONTAL);

l1.setPaintingStrategy(paintingStrategy.HORIZONTAL);
l2.setPaintingStrategy(paintingStrategy.HORIZONTAL);
l3.setPaintingStrategy(paintingStrategy.HORIZONTAL);
l4.setPaintingStrategy(paintingStrategy.HORIZONTAL);

u1.setdefaultcolor(color.dark_green);
u2.setdefaultcolor(color.light_green);
u3.setdefaultcolor(color.green);
u4.setdefaultcolor(color.green);

l1.setdefaultcolor(color.dark_red);
l2.setdefaultcolor(color.light_red);
l3.setdefaultcolor(color.red);
l4.setdefaultcolor(color.red);

highBreak.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
lowbreak.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_DOWN);
midHighBreak.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
midLowBreak.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_DOWN);
highQBreak.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
lowQBreak.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_DOWN);

highBreak.setdefaultcolor(color.dark_green);
lowbreak.setdefaultcolor(color.dark_red);
midHighBreak.setdefaultcolor(color.dark_green);
midLowBreak.setdefaultcolor(color.dark_red);
highQBreak.setdefaultcolor(color.dark_green);
lowQBreak.setdefaultcolor(color.dark_red);

longTarget1.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_DOWN);
longTarget2.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_DOWN);
longTarget3.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_DOWN);
longTarget4.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_DOWN);

shortTarget1.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
shortTarget2.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
shortTarget3.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
shortTarget4.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);

longTarget1.setdefaultcolor(color.dark_red);
longTarget2.setdefaultcolor(color.dark_red);
longTarget3.setdefaultcolor(color.dark_red);
longTarget4.setdefaultcolor(color.dark_red);

shortTarget1.setdefaultcolor(color.dark_green);
shortTarget2.setdefaultcolor(color.dark_green);
shortTarget3.setdefaultcolor(color.dark_green);
shortTarget4.setdefaultcolor(color.dark_green);






##############
 
Piper792

Piper792

New member
VIP
@VicD is there a way to put the price in the right/left axis vs a bubble?
 

Similar threads

Top