Globex High of Day / Low of Day

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.

BBDli4r.png


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
 
Solution
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.

BBDli4r.png


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...
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.

BBDli4r.png


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

This will plot the high/low with horizontal lines using the TPO Profile, ProfileHigh/Lows.

Screenshot 2023-06-10 093603.png
Code:
plot hhigh = reference TPOProfile("time per profile" = "DAY", "on expansion" = no).ProfileHigh;
plot llow  = reference TPOProfile("time per profile" = "DAY", "on expansion" = no).ProfileLow;
hhigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
llow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
 
Solution
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.

BBDli4r.png


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


this will find the high and low of a period, even if it spans midnight.
hilolines_08
post18
https://usethinkscript.com/threads/average-daily-range-indicator-for-thinkorswim.244/#post-66296


EDIT
or maybe this version is a better fit to the Q
hilolines_07
post42
https://usethinkscript.com/threads/...utures-for-thinkorswim.2087/page-3#post-58176
 
Last edited:
this will find the high and low of a period, even if it spans midnight.
hilolines_08
post18
https://usethinkscript.com/threads/average-daily-range-indicator-for-thinkorswim.244/#post-66296


EDIT
or maybe this version is a better fit to the Q
hilolines_07
post42
https://usethinkscript.com/threads/...utures-for-thinkorswim.2087/page-3#post-58176

Thanks @halcyonguy , I've actually used your study as a base code for another range measuring script. Its great. The problem in this case is you have to wait for the range to close before it will start giving you its length.

@SleepyZ Do you think there is a way to customize the start/end time of this script? I realize it may be limited by the time aggregations that the TPO is limited to. What you gave me is great for Globex Day. I'd love if there was a way to get it to work on a custom range though

Either way, thanks gang.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
446 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top