Cribbage
Member
I'd like a script that shows the highest high / lowest low of day. I tried refashioning the DR / IDR script but can only get it to go as far back as midnight. This gives an idea of what I want, but I just can't get the full range of Globex hours.
Keep in mind I'm in Colorado so midnight EST shows up as 2200. The earliest I can get it to start is midnight, I would like it to start at 1800 EST previous day to capture the Asian session as well. I'm including the code that I'm using which is just a pared down version of the code Sam4Cok@Samer800 wrote (linked above).

Keep in mind I'm in Colorado so midnight EST shows up as 2200. The earliest I can get it to start is midnight, I would like it to start at 1800 EST previous day to capture the Asian session as well. I'm including the code that I'm using which is just a pared down version of the code Sam4Cok@Samer800 wrote (linked above).
Code:
#import PineCoders/VisibleChart/4 as PCchart
#// © TheMas7er and bmistiaen
#indicator('DR/IDR V1', overlay=true, max_lines_count=500, max_boxes_count=500)
# Converted by Sam4Cok@Samer800 - 12/2022
# Edited by Cribbage into a single range 5/27/2023
declare hide_on_daily;
#//timings
input ShowTodayOnly = no; # 'Show complete history ?'
input exchangeOffset = 0; # 'Exchange Offset'
input regularTimeStart = 0930; # 'RDR Time'
input regularTimeEnd = 1600; # 'RDR Time'
input regularExtendStart = 1030; # 'RDR Lines Time'
input regularExtendEnd = 1600; # 'RDR Lines Time'
#//lines
input drLines = yes; # 'Show DR Lines ?'
input idrLines = yes; # 'Show IDR Lines ?'
input middleDrLine = no; # 'Show Middle DR Line ?'
input middleIdrLine = yes; # 'Show Middle IDR Line ?'
input ColorBox = yes; # 'Box color based on open and close'
input ShowCloud = {DR, default IDR, None}; # 'Show DR/IDR Box ?'
input extendDrLines = no; # 'Extend DR Lines ?'
input extendIdrLines = no; # 'Extend IDR Lines ?'
def na = Double.NaN;
def Cloud = if ShowCloud == ShowCloud.IDR then 1 else
if ShowCloud == ShowCloud.DR then -1 else
if ShowCloud == ShowCloud.None then 0 else Cloud[1];
def Highlight = Cloud;
def ExtDR = if !extendDrLines then IsNaN(close) else 0;
def ExtIDR = if !extendIdrLines then IsNaN(close) else 0;
def Today = if GetLastDay() == GetDay() then 1 else 0;
def CurrentAgg = GetAggregationPeriod();
def Agg = CurrentAgg < AggregationPeriod.DAY;
def m5_Agg = AggregationPeriod.FIVE_MIN;
#f_insession(_session) =>
script f_insession {
input _sessionStart = 0930;
input _sessionEnd = 1030;
def insession = if SecondsTillTime(_sessionEnd) > 0 and SecondsFromTime(_sessionStart) >= 0 then 1 else 0;
plot return = insession;
}
def m5_open = open (period = m5_Agg);
def m5_high = high (period = m5_Agg);
def m5_low = low (period = m5_Agg);
def m5_close = close(period = m5_Agg);
def open_value;
def high_value;
def low_value;
def close_value;
if CurrentAgg < m5_Agg {
open_value = m5_open;
high_value = m5_high;
low_value = m5_low;
close_value = m5_close;
} else {
open_value = open;
high_value = high;
low_value = low;
close_value = close;
}
def inRegularSession = f_insession(regularTimeStart, regularTimeEnd);
def inRegularExtend = f_insession(regularExtendStart, regularExtendEnd);
def inSession = inRegularSession;
def inExtend = inRegularExtend;
def sessionOpen;
def rdrhigh;
def rdrlow;
def ridrlow;
def ridrhigh;
if Agg and (Today or !ShowTodayOnly) {
if inSession {
if !inSession[1] {
sessionOpen = open_value;
rdrhigh = high_value;
rdrlow = low_value;
ridrhigh = Max(open_value, close_value);
ridrlow = Min(open_value, close_value);
} else {
sessionOpen = sessionOpen[1];
rdrhigh = Max(high_value, rdrhigh[1]);
rdrlow = Min(low_value, rdrlow[1]);
ridrhigh = Max(Max(open_value, close_value), ridrhigh[1]);
ridrlow = Min(Min(open_value, close_value), ridrlow[1]);
}
} else {
sessionOpen = na;
rdrhigh = rdrhigh[1];
rdrlow = rdrlow[1];
ridrlow = ridrlow[1];
ridrhigh = ridrhigh[1];
}
} else {
sessionOpen = na;
rdrhigh = na;
rdrlow = na;
ridrhigh = na;
ridrlow = na;
}
def boxUp;
def boxBackgroundColor;
def boxHighDR;
def boxLowDR;
def boxHighIDR;
def boxLowIDR;
if ColorBox and Highlight != 0 and inSession {
boxUp = close_value > sessionOpen;
boxBackgroundColor = If(boxUp, 1, -1);
boxHighDR = rdrhigh;
boxLowDR = rdrlow;
boxHighIDR = ridrhigh;
boxLowIDR = ridrlow;
} else {
boxUp = na;
boxBackgroundColor = if Highlight != 0 and inSession then 0 else na;
boxHighDR = if Highlight != 0 and inSession then rdrhigh else na;
boxLowDR = if Highlight != 0 and inSession then rdrlow else na;
boxHighIDR = if Highlight != 0 and inSession then ridrhigh else na;
boxLowIDR = if Highlight != 0 and inSession then ridrlow else na;
}
plot rdrhighLine = if !drLines or ExtDR or inSession then na else rdrhigh[exchangeOffset];
rdrhighLine.SetDefaultColor(Color.WHITE);
plot ridrhighLine = if !idrLines or ExtIDR or inSession then na else ridrhigh[exchangeOffset];
ridrhighLine.SetDefaultColor(Color.DARK_ORANGE);
ridrhighLine.SetStyle(Curve.LONG_DASH);
plot ridrlowLine = if !idrLines or ExtIDR or inSession then na else ridrlow[exchangeOffset];
ridrlowLine.SetDefaultColor(Color.DARK_ORANGE);
ridrlowLine.SetStyle(Curve.LONG_DASH);
plot rdrlowLine = if !drLines or ExtDR or inSession then na else rdrlow[exchangeOffset];
rdrlowLine.SetDefaultColor(Color.WHITE);
plot boxHdr = if !drLines then na else boxHighDR[exchangeOffset];
boxHdr.SetDefaultColor(Color.WHITE);
plot boxLdr = if !drLines then na else boxLowDR[exchangeOffset];
boxLdr.SetDefaultColor(Color.WHITE);
plot boxHidr = if !idrLines then na else boxHighIDR[exchangeOffset];
boxHidr.SetDefaultColor(Color.DARK_ORANGE);
plot boxLidr = if !idrLines then na else boxLowIDR[exchangeOffset];
boxLidr.SetDefaultColor(Color.DARK_ORANGE);
#--- Middle Lines
def drMid = (rdrhighLine + rdrlowLine) / 2;
def idrMid = (ridrhighLine + ridrlowLine) / 2;
def boxdrMid = (boxHdr + boxLdr) / 2;
def boxidrMid = (boxHidr + boxLidr) / 2;
plot drMidLine = if !middleDrLine then na else drMid;
drMidLine.SetDefaultColor(Color.GRAY);
plot idrMidLine = if !middleIdrLine then na else idrMid;
idrMidLine.SetDefaultColor(Color.GRAY);
idrMidLine.SetStyle(Curve.SHORT_DASH);
plot boxdrMidLine = if !middleDrLine then na else boxdrMid;
boxdrMidLine.SetDefaultColor(Color.GRAY);
plot boxidrMidLine = if !middleIdrLine then na else boxidrMid;
boxidrMidLine.SetDefaultColor(Color.GRAY);
boxidrMidLine.SetStyle(Curve.SHORT_DASH);
#-- highlights
def boxBGColor = boxBackgroundColor[exchangeOffset];
def boxH = if Highlight < 0 then boxHdr else boxHidr;
def boxL = if Highlight < 0 then boxLdr else boxLidr;
AddCloud(if boxBGColor > 0 and Highlight != 0 then boxH else if boxBGColor < 0 then boxL else na,
if boxBGColor > 0 and Highlight != 0 then boxL else if boxBGColor < 0 then boxH else na,
Color.DARK_GREEN, Color.DARK_RED);
AddCloud(if boxBGColor == 0 and Highlight != 0 then boxH else na, boxL, Color.GRAY, Color.GRAY);
#---- END Code