I just took a few scripts and pieced them together, but I find this incredibly visually helpful. I notice that the first bar on a five minute chart typically served as a great support and resistance indicator. Here's what it looks like https://imgur.com/a/MEIygEz
declare Hide_On_Daily;
declare Once_per_bar;
input OrMeanS = 0930.0; #hint OrMeanS: Begin Mean Period. Usually Market Open EST.
input OrMeanE = 0935.0; #hint OrMeanE: End Mean period. Usually End of first bar.
input OrBegin = 0930.0; #hint OrBegin: Beginning for Period of Opening Range Breakout.
input OrEnd = 0935.0; #hint OrEnd: End of Period of Opening Range Breakout.
input CloudOn = no; #hint CloudOn: Clouds Opening Range.
input AlertOn = no; #hint AlertOn: Alerts on cross of Opening Range.
input ShowTodayOnly = {"No", default "Yes"};
input nAtr = 4; #hint nATR: Lenght for the ATR Risk and Target Lines.
input AtrTargetMult = 2.0; #hint ATRmult: Multiplier for the ATR calculations.
######################################################
def h = high;
def l = low;
def op = open;
def c = close;
def bar = barNumber();
def s = ShowTodayOnly;
def ORActive = if secondsTillTime(OrMeanE) > 0 and
secondsFromTime(OrMeanS) >= 0
then 1
else 0;
def today = if s == 0
or getDay() == getLastDay() and
secondsFromTime(OrMeanS) >= 0
then 1
else 0;
####################################################################
def ORHigh = if ORHigh[1] == 0
or ORActive[1] == 0 and
ORActive == 1
then h
else if ORActive and
h > ORHigh[1]
then h
else ORHigh[1];
def ORLow = if ORLow[1] == 0
or ORActive[1] == 0 and
ORActive == 1
then l
else if ORActive and
l < ORLow[1]
then l
else ORLow[1];
def OROpen = if OROpen[1] == 0
or ORActive[1] == 0 and
ORActive == 1
then Op
else if ORActive and
Op > OROpen[1]
then Op
else OROpen[1];
def ORClose = if ORClose[1] == 0
or ORActive[1] == 0 and
ORActive == 1
then C
else if ORActive and
C > ORClose[1]
then C
else ORClose[1];
####################################################################
def ORWidth = ORHigh - ORLow;
def na = double.nan;
def ORHA = if ORActive
or today < 1
then na
else ORHigh;
def ORLA = if ORActive
or today < 1
then na
else ORLow;
def OROP = if ORActive
or today < 1
then na
else OROpen;
def ORCL = if ORActive
or today < 1
then na
else ORClose;
####################################################################
def O = ORHA - Round(((ORHA - ORLA) / 2) / TickSize(), 0) * TickSize();
def ORActive2 = if secondsTillTime(OREnd) > 0 and
secondsFromTime(ORBegin) >= 0
then 1
else 0;
def ORHigh2 = if ORHigh2[1] == 0
or ORActive2[1] == 0 and
ORActive2 == 1
then h
else if ORActive2 and
h > ORHigh2[1]
then h
else ORHigh2[1];
def ORLow2 = if ORLow2[1] == 0
or ORActive2[1] == 0 and
ORActive2 == 1
then l
else if ORActive2 and
l < ORLow2[1]
then l
else ORLow2[1];
def ORWidth2 = ORHigh2 - ORLow2;
def TimeLine = if secondsTillTime(OREnd) == 0
then 1
else 0;
def ORmeanBar = if !ORActive and ORActive[1]
then barNumber()
else ORmeanBar[1];
def ORendBar = if !ORActive2 and ORActive2[1]
then barNumber()
else ORendBar[1];
def ORL = if (o == 0 , na, o);
####################################################################
plot OR_Open = if barNumber() >= highestAll(ORmeanBar)
then HighestAll(if isNaN(c[-1])
then OROpen[1]
else double.nan)
else double.nan;
OR_Open.SetDefaultColor(color.Yellow);
OR_Open.SetStyle(curve.Long_DASH);
OR_Open.SetLineWeight(3);
OR_Open.HideTitle();
def ORH2 = if ORActive2
or today < 1
then na
else ORHigh2;
####################################################################
plot OR_Close = if barNumber() >= highestAll(ORmeanBar)
then HighestAll(if isNaN(c[-1])
then ORClose[1]
else double.nan)
else double.nan;
OR_Close.SetDefaultColor(color.Yellow);
OR_Close.SetStyle(curve.Long_DASH);
OR_Close.SetLineWeight(3);
OR_Close.HideTitle();
def OR_CL = if ORActive2
or today < 1
then na
else ORHigh2;
####################################################################
plot OR_High = if barNumber() >= highestAll(ORendBar)
then HighestAll(if isNaN(c[-1])
then ORH2[1]
else double.nan)
else double.nan;
OR_High.SetDefaultColor(color.Green);
OR_High.SetStyle(curve.Long_DASH);
OR_High.SetLineWeight(3);
OR_High.HideTitle();
def ORL2 = if ORActive2
or today < 1
then na
else ORLow2;
####################################################################
plot OR_Low = if barNumber() >= highestAll(ORendBar)
then HighestAll(if isNaN(c[-1])
then ORL2[1]
else double.nan)
else double.nan;
OR_Low.SetDefaultColor(color.Red);
OR_Low.SetStyle(curve.Long_DASH);
OR_Low.SetLineWeight(3);
OR_Low.HideTitle();
def RelDay = (ORL - ORL2) / (ORH2 - ORL2);
def dColor = if RelDay > .5
then 5
else if RelDay < .5
then 6
else 4;
def pos = (ORH2 - ORL2)/10;
####################################################################
addCloud(if CloudOn == yes
then orl
else double.nan
#, orl2,createColor(244,83,66), createColor(244,83,66));
, orl2, color.Black, color.black);
addCloud(if CloudOn == yes
then orl
else double.nan
#, orh2,createColor(66,244,131), createColor(66,244,131));
, orh2, color.Black, color.black);
# Begin Risk Algorithm
# First Breakout or Breakdown bars
def Bubbleloc1 = isNaN(close[-1]);
def BreakoutBar = if ORActive
then double.nan
else if !ORActive and c crosses above ORH2
then bar
else if !isNaN(BreakoutBar[1]) and c crosses ORH2
then BreakoutBar[1]
else BreakoutBar[1];
def ATR = if ORActive2
then Round((Average(TrueRange(h, c, l), nATR)) / TickSize(), 0) * TickSize()
else ATR[1];
def cond1 = if h > ORH2 and
h[1] <= ORH2
then Round((ORH2 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
else cond1[1];
######################################
Input Five_Min_Cloud = yes;
def Bullish_Open = OR_Close is greater than OR_Open;
AddCloud(if Bullish_Open && Five_Min_Cloud then OR_High else Double.NaN, OR_Close, Color.Red, Color.Green);
AddCloud(if Bullish_Open && Five_Min_Cloud then OR_Low else Double.NaN, OR_Open, Color.Red, Color.Green);
def Bearish_Open = OR_Close is less than OR_Open;
AddCloud(if Bearish_Open && Five_Min_Cloud then OR_High else Double.NaN, OR_Open, Color.Red, Color.Green);
AddCloud(if Bearish_Open && Five_Min_Cloud then OR_Low else Double.NaN, OR_Close, Color.Red, Color.Green);
######################################
OR_Close.AssignValueColor(if OR_Close > OR_Open then color.Dark_Red else color.Dark_Green);
OR_Open.AssignValueColor(if OR_Close > OR_Open then color.Dark_Green else color.Dark_Red);
declare Hide_On_Daily;
declare Once_per_bar;
input OrMeanS = 0930.0; #hint OrMeanS: Begin Mean Period. Usually Market Open EST.
input OrMeanE = 0935.0; #hint OrMeanE: End Mean period. Usually End of first bar.
input OrBegin = 0930.0; #hint OrBegin: Beginning for Period of Opening Range Breakout.
input OrEnd = 0935.0; #hint OrEnd: End of Period of Opening Range Breakout.
input CloudOn = no; #hint CloudOn: Clouds Opening Range.
input AlertOn = no; #hint AlertOn: Alerts on cross of Opening Range.
input ShowTodayOnly = {"No", default "Yes"};
input nAtr = 4; #hint nATR: Lenght for the ATR Risk and Target Lines.
input AtrTargetMult = 2.0; #hint ATRmult: Multiplier for the ATR calculations.
######################################################
def h = high;
def l = low;
def op = open;
def c = close;
def bar = barNumber();
def s = ShowTodayOnly;
def ORActive = if secondsTillTime(OrMeanE) > 0 and
secondsFromTime(OrMeanS) >= 0
then 1
else 0;
def today = if s == 0
or getDay() == getLastDay() and
secondsFromTime(OrMeanS) >= 0
then 1
else 0;
####################################################################
def ORHigh = if ORHigh[1] == 0
or ORActive[1] == 0 and
ORActive == 1
then h
else if ORActive and
h > ORHigh[1]
then h
else ORHigh[1];
def ORLow = if ORLow[1] == 0
or ORActive[1] == 0 and
ORActive == 1
then l
else if ORActive and
l < ORLow[1]
then l
else ORLow[1];
def OROpen = if OROpen[1] == 0
or ORActive[1] == 0 and
ORActive == 1
then Op
else if ORActive and
Op > OROpen[1]
then Op
else OROpen[1];
def ORClose = if ORClose[1] == 0
or ORActive[1] == 0 and
ORActive == 1
then C
else if ORActive and
C > ORClose[1]
then C
else ORClose[1];
####################################################################
def ORWidth = ORHigh - ORLow;
def na = double.nan;
def ORHA = if ORActive
or today < 1
then na
else ORHigh;
def ORLA = if ORActive
or today < 1
then na
else ORLow;
def OROP = if ORActive
or today < 1
then na
else OROpen;
def ORCL = if ORActive
or today < 1
then na
else ORClose;
####################################################################
def O = ORHA - Round(((ORHA - ORLA) / 2) / TickSize(), 0) * TickSize();
def ORActive2 = if secondsTillTime(OREnd) > 0 and
secondsFromTime(ORBegin) >= 0
then 1
else 0;
def ORHigh2 = if ORHigh2[1] == 0
or ORActive2[1] == 0 and
ORActive2 == 1
then h
else if ORActive2 and
h > ORHigh2[1]
then h
else ORHigh2[1];
def ORLow2 = if ORLow2[1] == 0
or ORActive2[1] == 0 and
ORActive2 == 1
then l
else if ORActive2 and
l < ORLow2[1]
then l
else ORLow2[1];
def ORWidth2 = ORHigh2 - ORLow2;
def TimeLine = if secondsTillTime(OREnd) == 0
then 1
else 0;
def ORmeanBar = if !ORActive and ORActive[1]
then barNumber()
else ORmeanBar[1];
def ORendBar = if !ORActive2 and ORActive2[1]
then barNumber()
else ORendBar[1];
def ORL = if (o == 0 , na, o);
####################################################################
plot OR_Open = if barNumber() >= highestAll(ORmeanBar)
then HighestAll(if isNaN(c[-1])
then OROpen[1]
else double.nan)
else double.nan;
OR_Open.SetDefaultColor(color.Yellow);
OR_Open.SetStyle(curve.Long_DASH);
OR_Open.SetLineWeight(3);
OR_Open.HideTitle();
def ORH2 = if ORActive2
or today < 1
then na
else ORHigh2;
####################################################################
plot OR_Close = if barNumber() >= highestAll(ORmeanBar)
then HighestAll(if isNaN(c[-1])
then ORClose[1]
else double.nan)
else double.nan;
OR_Close.SetDefaultColor(color.Yellow);
OR_Close.SetStyle(curve.Long_DASH);
OR_Close.SetLineWeight(3);
OR_Close.HideTitle();
def OR_CL = if ORActive2
or today < 1
then na
else ORHigh2;
####################################################################
plot OR_High = if barNumber() >= highestAll(ORendBar)
then HighestAll(if isNaN(c[-1])
then ORH2[1]
else double.nan)
else double.nan;
OR_High.SetDefaultColor(color.Green);
OR_High.SetStyle(curve.Long_DASH);
OR_High.SetLineWeight(3);
OR_High.HideTitle();
def ORL2 = if ORActive2
or today < 1
then na
else ORLow2;
####################################################################
plot OR_Low = if barNumber() >= highestAll(ORendBar)
then HighestAll(if isNaN(c[-1])
then ORL2[1]
else double.nan)
else double.nan;
OR_Low.SetDefaultColor(color.Red);
OR_Low.SetStyle(curve.Long_DASH);
OR_Low.SetLineWeight(3);
OR_Low.HideTitle();
def RelDay = (ORL - ORL2) / (ORH2 - ORL2);
def dColor = if RelDay > .5
then 5
else if RelDay < .5
then 6
else 4;
def pos = (ORH2 - ORL2)/10;
####################################################################
addCloud(if CloudOn == yes
then orl
else double.nan
#, orl2,createColor(244,83,66), createColor(244,83,66));
, orl2, color.Black, color.black);
addCloud(if CloudOn == yes
then orl
else double.nan
#, orh2,createColor(66,244,131), createColor(66,244,131));
, orh2, color.Black, color.black);
# Begin Risk Algorithm
# First Breakout or Breakdown bars
def Bubbleloc1 = isNaN(close[-1]);
def BreakoutBar = if ORActive
then double.nan
else if !ORActive and c crosses above ORH2
then bar
else if !isNaN(BreakoutBar[1]) and c crosses ORH2
then BreakoutBar[1]
else BreakoutBar[1];
def ATR = if ORActive2
then Round((Average(TrueRange(h, c, l), nATR)) / TickSize(), 0) * TickSize()
else ATR[1];
def cond1 = if h > ORH2 and
h[1] <= ORH2
then Round((ORH2 + (ATR * AtrTargetMult)) / TickSize(), 0) * TickSize()
else cond1[1];
######################################
Input Five_Min_Cloud = yes;
def Bullish_Open = OR_Close is greater than OR_Open;
AddCloud(if Bullish_Open && Five_Min_Cloud then OR_High else Double.NaN, OR_Close, Color.Red, Color.Green);
AddCloud(if Bullish_Open && Five_Min_Cloud then OR_Low else Double.NaN, OR_Open, Color.Red, Color.Green);
def Bearish_Open = OR_Close is less than OR_Open;
AddCloud(if Bearish_Open && Five_Min_Cloud then OR_High else Double.NaN, OR_Open, Color.Red, Color.Green);
AddCloud(if Bearish_Open && Five_Min_Cloud then OR_Low else Double.NaN, OR_Close, Color.Red, Color.Green);
######################################
OR_Close.AssignValueColor(if OR_Close > OR_Open then color.Dark_Red else color.Dark_Green);
OR_Open.AssignValueColor(if OR_Close > OR_Open then color.Dark_Green else color.Dark_Red);
Last edited: