DR IDR conversion

BannonMan85

New member
Platform
  1. Thinkorswim
Can we get this one converted? It works for the 5 minute time frame and the claim by "The Mas7er is that this indicator helps identify levels with an 88% probability of showing daily bias.

<iframe width="560" height="315" src="
" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Code:
rsion=5
indicator('DR/IDR V1.3', overlay=true, max_lines_count=500, max_boxes_count=500)
import PineCoders/VisibleChart/4 as PCchart

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TheMas7er and bmistiaen

// Input options
// {
LS0='Solid', LS1='Dashed', LS2='Dotted'
BX0='DR', BX1='IDR'
// } Input options


// Inputs
// {
var GRP1 = "Time Settings"
//timings
exchangeOffset      = input.int(0,"Exchange Offset (hours)", group=GRP1)
regularTime         = input.session('0930-1030', 'RDR Time', group=GRP1)
regularExtend       = input.session('1030-1600', 'RDR Lines Time', group=GRP1)
afterTime           = input.session('1930-2030', 'ADR Time', group=GRP1)
afterExtend         = input.session('2030-0200', 'ADR Lines Time', group=GRP1)
overnightTime       = input.session('0300-0400', 'ODR Time', group=GRP1)
overnightExtend     = input.session('0400-0830', 'ODR Lines Time', group=GRP1)

var GRP2 = "General Settings"
//lines
showRegular         = input.bool(true, 'Regular',                                 group=GRP2, inline='session',       tooltip='Show Regular and/or After and/or Overnight session')
showAfter           = input.bool(true, 'After',                                   group=GRP2, inline='session')
showOvernight       = input.bool(true, 'Overnight',                               group=GRP2, inline='session')
drlines             = input.bool(true, 'Show DR Lines ?', group=GRP2)
idrlines            = input.bool(true, 'Show IDR Lines ?', group=GRP2)
middledrline        = input.bool(false, 'Show Middle DR Line ?', group=GRP2)
middleidrline       = input.bool(true, 'Show Middle IDR Line ?', group=GRP2)
openline            = input.bool(true, 'Show Opening Line ?',                     group=GRP2, inline='openline',      tooltip='Shows the Opening line of the Defining Range.\n- Extend: Extends the drawing of the Opening line into the RDR/ODR Lines Time.')
extendopLines       = input.bool(true, 'Extend',                                  group=GRP2, inline='openline')
showBackground      = input.bool(true, 'Show DR/IDR Box ?', group=GRP2)
boxType             = input.string(BX1, 'Box DR or IDR ?', options=[BX0,BX1], group=GRP2)
extenddrLines       = input.bool(true, 'Extend DR Lines ?', group=GRP2)
extendidrLines      = input.bool(true, 'Extend IDR Lines ?', group=GRP2)
showAllHistory      = input.bool(false, 'Show complete history ?', 'Might cause a slight drawing delay when panning/moving/zooming the chart.', group=GRP2)
useBoxColors        = input.bool(false, 'Box color based on open and close', 'If unchecked, it will default to the selected Box Background Color', group=GRP2)


var GRP3 = "Styles"
linesWidth          = input.int(1, 'Box And Lines Width ?', minval=1, maxval=4, group=GRP3)
drLineColor         = input.color(color.gray, 'DR Line Color', group=GRP3, inline='drline')
drLineStyle         = input.string(LS0, 'Style', options=[LS0,LS1,LS2], group=GRP3, inline='drline')
idrLineColor        = input.color(color.red, 'IDR Line Color', group=GRP3, inline='idrline')
idrLineStyle        = input.string(LS1, 'Style', options=[LS0,LS1,LS2], group=GRP3, inline='idrline')
middleLineColor     = input.color(color.gray, 'Middle Line Color', group=GRP3, inline='midline')
middleLineStyle     = input.string(LS2, 'Style', options=[LS0,LS1,LS2], group=GRP3, inline='midline')
opLineColor         = input.color(color.green, 'Opening Line',                  group=GRP3, inline='openline',      tooltip='Opening line:\n- Color\n- Style\n- Width')
opLineStyle         = input.string(LS2, '', options=[LS0,LS1,LS2],                group=GRP3, inline='openline')
backgroundColor     = input.color(color.new(color.gray, 75), 'Box Background Color', group=GRP3)
boxBorderSize       = input.int(0, title="Box border size", minval=0, group=GRP3)
upBoxColor          = input.color(color.new(color.green, 85), 'Up box', group=GRP3, inline='upbox')
upBorderColor       = input.color(color.green, 'border', group=GRP3, inline='upbox')
downBoxColor        = input.color(color.new(color.red, 85), 'Down box', group=GRP3, inline='downbox')
downBorderColor     = input.color(color.red, 'border', group=GRP3, inline='downbox')


// } Inputs
 
 
// Constants
// {
exchangeOffsetMS = exchangeOffset * 3600000
// } Constants
 
 
// Variables {
var int     startTime           = na

var line    lowrdrl             = na
var line    highrdrl            = na
var line    lowridrl            = na
var line    highridrl           = na
var line    leftrdrl            = na
var line    rightrdrl           = na
var line    middlerdrl          = na
var line    middleridrl         = na
var line    drLineOpen          = na
var box     bgBox               = na

var float   rdrlow              = na
var float   rdrhigh             = na
var float   ridrlow             = na
var float   ridrhigh            = na
var float   rdrmiddle           = na
var float   ridrmiddle          = na
var float   sessionOpen         = na

var bool    use_m5              = false
// } Variables
 
 
// Functions {
f_insession(_session) =>
    not na(time(timeframe.period, _session, "America/New_York"))
  

f_lineStyle(_inputOption) =>
    switch(_inputOption)
        LS0 => line.style_solid
        LS1 => line.style_dashed
        LS2 => line.style_dotted
        => line.style_solid

f_newline(_color, _style) => line.new(na, na, na, na, xloc=xloc.bar_time, color=_color, style=_style, width=linesWidth)
f_newdrline()   => f_newline(drLineColor, f_lineStyle(drLineStyle))
f_newidrline()  => f_newline(idrLineColor, f_lineStyle(idrLineStyle))
f_newmdline()   => f_newline(middleLineColor, f_lineStyle(middleLineStyle))
f_newopline()   => f_newline(opLineColor, f_lineStyle(opLineStyle))

f_newbox()      => box.new(na, na, na, na, xloc=xloc.bar_time, bgcolor=backgroundColor, border_width=boxBorderSize)
 
f_moveLine(_line, _x1, _y, _x2) => line.set_xy1(_line, _x1 + exchangeOffsetMS, _y), line.set_xy2(_line, _x2 + exchangeOffsetMS, _y)

f_movebox(_box, _left, _top, _right, _bottom, _bordercolor, _bgcolor) => box.set_lefttop(_box, _left + exchangeOffsetMS, _top), box.set_rightbottom(_box, _right + exchangeOffsetMS, _bottom), box.set_border_color(_box, _bordercolor), box.set_bgcolor(_box, _bgcolor)

// } Functions
 
// Use the 5 minute timeframe if the chart timeframe is lower than 5m
if barstate.isfirst
    use_m5 := timeframe.in_seconds() < 300
 
[m5_open, m5_high, m5_low, m5_close] = request.security(syminfo.tickerid, '5', [open, high, low, close], lookahead = barmerge.lookahead_on)
 
open_value  = use_m5 ? m5_open  : open
high_value  = use_m5 ? m5_high  : high
low_value   = use_m5 ? m5_low   : low
close_value = use_m5 ? m5_close : close
 
inRegularSession    = f_insession(regularTime)     and showRegular
inRegularExtend     = f_insession(regularExtend)   and showRegular
inAfterSession      = f_insession(afterTime)       and showAfter
inAfterExtend       = f_insession(afterExtend)     and showAfter
inOvernightSession  = f_insession(overnightTime)   and showOvernight
inOvernightExtend   = f_insession(overnightExtend) and showOvernight

inSession = inRegularSession or inOvernightSession or inAfterSession
inExtend  = inRegularExtend or inOvernightExtend or inAfterExtend
 
if timeframe.isintraday and (PCchart.barIsVisible() or not showAllHistory)
    if inSession
 
        // Initialize levels
        if not inSession[1]
            startTime   := time
            sessionOpen := open_value
            rdrhigh     := high_value
            rdrlow      := low_value
            ridrlow     := math.min(open_value, close_value)
            ridrhigh    := math.max(open_value, close_value)
 
            // Initialize drawing objects
            if showBackground
                bgBox       := f_newbox()
 
            if drlines
                highrdrl    := f_newdrline()
                lowrdrl     := f_newdrline()

            if idrlines
                highridrl   := f_newidrline()
                lowridrl    := f_newidrline()
 
            if middledrline
                middlerdrl  := f_newmdline()
            
            if middleidrline
                middleridrl := f_newmdline()
 
            if openline
                drLineOpen    := f_newopline()

        // Calculate levels
        rdrhigh     := math.max(high_value, rdrhigh)
        rdrlow      := math.min(low_value, rdrlow)
        ridrhigh    := math.max(open_value, close_value, ridrhigh)
        ridrlow     := math.min(open_value, close_value, ridrlow)
        rdrmiddle   := math.avg(rdrhigh, rdrlow)
        ridrmiddle  := math.avg(ridrhigh, ridrlow)

    // Draw objects
    if showBackground and inSession
        boxUp               = close_value > sessionOpen
        boxBorderColor      = useBoxColors ? (boxUp ? upBorderColor : downBorderColor) : backgroundColor
        boxBackgroundColor  = useBoxColors ? (boxUp ? upBoxColor    : downBoxColor)    : backgroundColor
        boxHigh             = boxType==BX0 ? rdrhigh : ridrhigh
        boxLow              = boxType==BX0 ? rdrlow  : ridrlow
        f_movebox(bgBox, startTime, boxHigh, time, boxLow, boxBorderColor, boxBackgroundColor)
 
    if drlines and (inSession or (extenddrLines and inExtend))
        f_moveLine(highrdrl, startTime, rdrhigh, time)
        f_moveLine(lowrdrl, startTime, rdrlow, time)
        if middledrline
            f_moveLine(middlerdrl, startTime, rdrmiddle, time)
    
    if idrlines and (inSession or (extendidrLines and inExtend))
        f_moveLine(highridrl, startTime, ridrhigh, time)
        f_moveLine(lowridrl, startTime, ridrlow, time)
        if middleidrline
            f_moveLine(middleridrl, startTime, ridrmiddle, time)

    if openline and (inSession or (extendopLines and inExtend))
        f_moveLine(drLineOpen, startTime, sessionOpen, time)
 

barbaros

Administrator
Staff member
In that case, it may be easier for us to write a brand new indicator for the concept instead of converting this one to one.
 

BannonMan85

New member
I would like to try it along with a few other indicators including B4 in order to see if B4 can filter out some of the false signals. He uses this along with ICT concepts to make his trades. There are 2 other videos that he has that go into more advanced details and there are others that have posted videos on how they use it in there own trading as well
 

barbaros

Administrator
Staff member
I can't get the exact look with Thinkscript but end result is similar. Let us know what you find out from your backtesting @BannonMan85.

v1bWmQb.png


Code:
# DR / IDR
# Free for use. Header credits must be included when any form of the code included in this package is used.
# Any indicator built on this indicator needs to attribute the original author's work
# v1.0 - barbaros - released for b4indicators.com

declare hide_on_daily;

input RDRStart  = 930;
input RDREnd    = 1030;
input RDRExtend = 1600;
input ADRStart  = 1930;
input ADREnd    = 2030;
input ADRExtend = 200;
input ODRStart  = 300;
input ODREnd    = 400;
input ODRExtend = 830;

script nz {
    input val = close;
    input rep = close;
    plot result = if isNaN(val) then rep else val;
}

script isBetweenTime {
    input startTime = 900;
    input endTime = 1400;
    plot result = if endTime < startTime then (SecondsFromTime(startTime) >= 0 and SecondsTillTime(2359) >= 0) or (SecondsFromTime(2359) >= 0 and SecondsTillTime(endTime) >= 0)
                  else SecondsFromTime(startTime) >= 0 and SecondsTillTime(endTime) >= 0;
}

def ocmax = max(open, close);
def ocmin = min(open, close);

# RDR

def RDR_Open_ = if SecondsFromTime(RDRStart) == 0 then open
                else if isBetweenTime(RDRStart, RDRExtend) then RDR_Open_[1]
                else Double.NaN;
def RDR_DR_HH_ = if isBetweenTime(RDRStart, RDREnd) and high > nz(RDR_DR_HH_[1], Double.NEGATIVE_INFINITY) then high
              else if isBetweenTime(RDRStart, RDRExtend) then RDR_DR_HH_[1]
              else Double.NaN;

def RDR_DR_LL_ = if isBetweenTime(RDRStart, RDREnd) and low < nz(RDR_DR_LL_[1], Double.POSITIVE_INFINITY) then low
              else if isBetweenTime(RDRStart, RDRExtend) then RDR_DR_LL_[1]
              else Double.NaN;

def RDR_IDR_HH_ = if isBetweenTime(RDRStart, RDREnd) and ocmax > nz(RDR_IDR_HH_[1], Double.NEGATIVE_INFINITY) then ocmax
              else if isBetweenTime(RDRStart, RDRExtend) then RDR_IDR_HH_[1]
              else Double.NaN;

def RDR_IDR_LL_ = if isBetweenTime(RDRStart, RDREnd) and ocmin < nz(RDR_IDR_LL_[1], Double.POSITIVE_INFINITY) then ocmin
              else if isBetweenTime(RDRStart, RDRExtend) then RDR_IDR_LL_[1]
              else Double.NaN;

plot RDR_Open = if isBetweenTime(RDREnd, RDRExtend) then RDR_Open_ else Double.NaN;
RDR_Open.SetPaintingStrategy(PaintingStrategy.DASHES);
RDR_Open.SetDefaultColor(Color.WHITE);

plot RDR_DR_HH = if isBetweenTime(RDREnd, RDRExtend) then RDR_DR_HH_ else Double.NaN;
RDR_DR_HH.SetDefaultColor(Color.GREEN);

plot RDR_DR_LL = if isBetweenTime(RDREnd, RDRExtend) then RDR_DR_LL_ else Double.NaN;
RDR_DR_LL.SetDefaultColor(Color.RED);

plot RDR_IDR_HH = if isBetweenTime(RDREnd, RDRExtend) then RDR_IDR_HH_ else Double.NaN;
RDR_IDR_HH.SetDefaultColor(Color.MAGENTA);

plot RDR_IDR_LL = if isBetweenTime(RDREnd, RDRExtend) then RDR_IDR_LL_ else Double.NaN;
RDR_IDR_LL.SetDefaultColor(Color.MAGENTA);

plot RDR_DR_MID = if isBetweenTime(RDREnd, RDRExtend) then (RDR_DR_HH+RDR_DR_LL)/2 else Double.NaN;
RDR_DR_MID.SetDefaultColor(Color.LIGHT_GRAY);

AddCloud(RDR_IDR_HH, RDR_IDR_LL, Color.DARK_GRAY, Color.DARK_GRAY, no);

AddVerticalLine(SecondsFromTime(RDREnd) == 0, "RDR End", Color.GRAY, Curve.SHORT_DASH);

# ADR

def ADR_Open_ = if SecondsFromTime(ADRStart) == 0 then open
else if isBetweenTime(ADRStart, ADRExtend) then ADR_Open_[1]
else Double.NaN;
def ADR_DR_HH_ = if isBetweenTime(ADRStart, ADREnd) and high > nz(ADR_DR_HH_[1], Double.NEGATIVE_INFINITY) then high
else if isBetweenTime(ADRStart, ADRExtend) then ADR_DR_HH_[1]
else Double.NaN;

def ADR_DR_LL_ = if isBetweenTime(ADRStart, ADREnd) and low < nz(ADR_DR_LL_[1], Double.POSITIVE_INFINITY) then low
else if isBetweenTime(ADRStart, ADRExtend) then ADR_DR_LL_[1]
else Double.NaN;

def ADR_IDR_HH_ = if isBetweenTime(ADRStart, ADREnd) and ocmax > nz(ADR_IDR_HH_[1], Double.NEGATIVE_INFINITY) then ocmax
else if isBetweenTime(ADRStart, ADRExtend) then ADR_IDR_HH_[1]
else Double.NaN;

def ADR_IDR_LL_ = if isBetweenTime(ADRStart, ADREnd) and ocmin < nz(ADR_IDR_LL_[1], Double.POSITIVE_INFINITY) then ocmin
else if isBetweenTime(ADRStart, ADRExtend) then ADR_IDR_LL_[1]
else Double.NaN;

plot ADR_Open = if isBetweenTime(ADREnd, ADRExtend) then ADR_Open_ else Double.NaN;
ADR_Open.SetPaintingStrategy(PaintingStrategy.DASHES);
ADR_Open.SetDefaultColor(Color.WHITE);

plot ADR_DR_HH = if isBetweenTime(ADREnd, ADRExtend) then ADR_DR_HH_ else Double.NaN;
ADR_DR_HH.SetDefaultColor(Color.GREEN);

plot ADR_DR_LL = if isBetweenTime(ADREnd, ADRExtend) then ADR_DR_LL_ else Double.NaN;
ADR_DR_LL.SetDefaultColor(Color.RED);

plot ADR_IDR_HH = if isBetweenTime(ADREnd, ADRExtend) then ADR_IDR_HH_ else Double.NaN;
ADR_IDR_HH.SetDefaultColor(Color.MAGENTA);

plot ADR_IDR_LL = if isBetweenTime(ADREnd, ADRExtend) then ADR_IDR_LL_ else Double.NaN;
ADR_IDR_LL.SetDefaultColor(Color.MAGENTA);

plot ADR_DR_MID = if isBetweenTime(ADREnd, ADRExtend) then (ADR_DR_HH+ADR_DR_LL)/2 else Double.NaN;
ADR_DR_MID.SetDefaultColor(Color.LIGHT_GRAY);

AddCloud(ADR_IDR_HH, ADR_IDR_LL, Color.DARK_GRAY, Color.DARK_GRAY, no);

AddVerticalLine(SecondsFromTime(ADREnd) == 0, "ADR End", Color.GRAY, Curve.SHORT_DASH);

# ODR

def ODR_Open_ = if SecondsFromTime(ODRStart) == 0 then open
else if isBetweenTime(ODRStart, ODRExtend) then ODR_Open_[1]
else Double.NaN;
def ODR_DR_HH_ = if isBetweenTime(ODRStart, ODREnd) and high > nz(ODR_DR_HH_[1], Double.NEGATIVE_INFINITY) then high
else if isBetweenTime(ODRStart, ODRExtend) then ODR_DR_HH_[1]
else Double.NaN;

def ODR_DR_LL_ = if isBetweenTime(ODRStart, ODREnd) and low < nz(ODR_DR_LL_[1], Double.POSITIVE_INFINITY) then low
else if isBetweenTime(ODRStart, ODRExtend) then ODR_DR_LL_[1]
else Double.NaN;

def ODR_IDR_HH_ = if isBetweenTime(ODRStart, ODREnd) and ocmax > nz(ODR_IDR_HH_[1], Double.NEGATIVE_INFINITY) then ocmax
else if isBetweenTime(ODRStart, ODRExtend) then ODR_IDR_HH_[1]
else Double.NaN;

def ODR_IDR_LL_ = if isBetweenTime(ODRStart, ODREnd) and ocmin < nz(ODR_IDR_LL_[1], Double.POSITIVE_INFINITY) then ocmin
else if isBetweenTime(ODRStart, ODRExtend) then ODR_IDR_LL_[1]
else Double.NaN;

plot ODR_Open = if isBetweenTime(ODREnd, ODRExtend) then ODR_Open_ else Double.NaN;
ODR_Open.SetPaintingStrategy(PaintingStrategy.DASHES);
ODR_Open.SetDefaultColor(Color.WHITE);

plot ODR_DR_HH = if isBetweenTime(ODREnd, ODRExtend) then ODR_DR_HH_ else Double.NaN;
ODR_DR_HH.SetDefaultColor(Color.GREEN);

plot ODR_DR_LL = if isBetweenTime(ODREnd, ODRExtend) then ODR_DR_LL_ else Double.NaN;
ODR_DR_LL.SetDefaultColor(Color.RED);

plot ODR_IDR_HH = if isBetweenTime(ODREnd, ODRExtend) then ODR_IDR_HH_ else Double.NaN;
ODR_IDR_HH.SetDefaultColor(Color.MAGENTA);

plot ODR_IDR_LL = if isBetweenTime(ODREnd, ODRExtend) then ODR_IDR_LL_ else Double.NaN;
ODR_IDR_LL.SetDefaultColor(Color.MAGENTA);

plot ODR_DR_MID = if isBetweenTime(ODREnd, ODRExtend) then (ODR_DR_HH+ODR_DR_LL)/2 else Double.NaN;
ODR_DR_MID.SetDefaultColor(Color.LIGHT_GRAY);

AddCloud(ODR_IDR_HH, ODR_IDR_LL, Color.DARK_GRAY, Color.DARK_GRAY, no);

AddVerticalLine(SecondsFromTime(ODREnd) == 0, "ODR End", Color.GRAY, Curve.SHORT_DASH);
 

BannonMan85

New member
just in my light observations on SPY from last night and this evening is that the ODR(overnight) bias will give an idea of what the bias is for the day. I haven't found an indicator that I like to put with it just yet. Still have to look at the most effective way to apply it. I am wondering if I DO have to use FVG and other ICT concepts to make this thing work. Funny thing is that I found his discord and he posted his own TOS script, but it doesn't take into account the after hours and overnight sessions. What do you think @barbaros?

Code:
# Automatic Opening Range and Fibonacci Levels

# By Prospectus @ https://readtheprospectus.wordpress.com

# Inspired by Trader-X @ http://traderx.blogspot.com

#

# This Thinkscript is designed to plot the OR high, low,

# 50% fib retrace, and fib extensions for the current day.

# This will only work correctly on time-based charts,

# where the OR timeframe is divisible by the bar period

# e.g. 30 minute OR, 10 min bars. An extra fib extension

# may be used if desired to create a target zone.

# Added additional Fib_exts_.  Horserider 12/14/2019

def na = Double.NaN;

#

# Define time that OR begins (in hhmm format,

# 0930 is the default):

#

input ORBegin = 0930;

#

# Define time that OR is finished (in hhmm format,

# 10:00 is the default):

#

input OREnd = 1030;

#

# Input first and second fib extension levels

# (default 1.382, 1.621):

#

input FibExt1 = -0.5;

input FibExt2 = 1;

input FibExt3 = -1;

input FibExt4 = 1.5;

input FibExt5 = -1.5;

input FibExt6 = 2;

input FibExt7 = -2;

input FibExt8 = 2.5;

input FibExt9 = -2.5;

input FibExt10 = 3;

input FibExt11 = 3.5;



#

# Show Today only? (Default Yes)

#

input ShowTodayOnly = {"No", default "Yes"};

def s = ShowTodayOnly;

#

# Show Second fib extension? (Default Yes)

#

input ShowFibExt2 = {"No", default "Yes"};

def sf2 = ShowFibExt2;

#

input ShowRangeCloud = No;
# Create logic for OR definition:

#

def ORActive = if SecondsTillTime(OREnd) > 0 and SecondsFromTime(ORBegin) >= 0 then 1 else 0;

#

# Create logic to paint only current day post-open:

#

def today = if s == 0 or GetDay() == GetLastDay() and SecondsFromTime(ORBegin) >= 0 then 1 else 0;

#

# Track OR High:

#

rec ORHigh = if ORHigh[1] == 0 or ORActive[1] == 0 and ORActive == 1 then high else if ORActive and high > ORHigh[1] then high else ORHigh[1];

#

# Track OR Low:

#

rec ORLow = if ORLow[1] == 0 or ORActive[1] == 0 and ORActive == 1 then low else if ORActive and low < ORLow[1] then low else ORLow[1];

#

# Calculate OR width:

#

def ORWidth = ORHigh - ORLow;

#

# Calculate fib levels:

#

def fib_mid = (ORHigh + ORLow) / 2;



def fib_ext_up1 = ORHigh + ORWidth * (FibExt1 - 1);

def fib_ext_down1 = ORLow - ORWidth * (FibExt1 - 1);

def fib_ext_up2 = ORHigh + ORWidth * (FibExt2 - 1);

def fib_ext_down2 = ORLow - ORWidth * (FibExt2 - 1);

def fib_ext_up3 = ORHigh + ORWidth * (FibExt3 - 1);

def fib_ext_down3 = ORLow - ORWidth * (FibExt3 - 1);

def fib_ext_up4 = ORHigh + ORWidth * (FibExt4 - 1);

def fib_ext_down4 = ORLow - ORWidth * (FibExt4 - 1);

def fib_ext_up5 = ORHigh + ORWidth * (FibExt5 - 1);

def fib_ext_down5 = ORLow - ORWidth * (FibExt5 - 1);

def fib_ext_up6 = ORHigh + ORWidth * (FibExt6 - 1);

def fib_ext_up7 = ORHigh + ORWidth * (FibExt7 - 1);

def fib_ext_up8 = ORHigh + ORWidth * (FibExt8 - 1);

def fib_ext_up9 = ORHigh + ORWidth * (FibExt9 - 1);

def fib_ext_up10 = ORHigh + ORWidth * (FibExt10 - 1);

def fib_ext_up11 = ORHigh + ORWidth * (FibExt11 - 1);

#

# Define all the plots:

#

plot ORH = if ORActive or today < 1 then na else ORHigh;

plot ORL = if ORActive or today < 1 then na else ORLow;

plot FibMid = if ORActive or today < 1 then na else fib_mid;

plot FibExtUp1 = if ORActive or today < 1 then na else fib_ext_up1;

plot FibExtDown1 = if ORActive or today < 1 then na else fib_ext_down1;

plot FibExtUp2 = if ORActive or today < 1 or sf2 < 1 then na else fib_ext_up2;

plot FibExtDown2 = if ORActive or today < 1 or sf2 < 1 then na else fib_ext_down2;


plot FibExtUp3 = if ORActive or today < 1 then na else fib_ext_up3;

plot FibExtDown3 = if ORActive or today < 1 then na else fib_ext_down3;

plot FibExtUp4 = if ORActive or today < 1 or sf2 < 1 then na else fib_ext_up4;

plot FibExtDown4 = if ORActive or today < 1 or sf2 < 1 then na else fib_ext_down4;

plot FibExtUp5 = if ORActive or today < 1 or sf2 < 1 then na else fib_ext_up5;

plot FibExtDown5 = if ORActive or today < 1 or sf2 < 1 then na else fib_ext_down5;

plot FibExtUp6 = if ORActive or today < 1 or sf2 < 1 then na else fib_ext_up6;

plot FibExtUp7 = if ORActive or today < 1 or sf2 < 1 then na else fib_ext_up7;

plot FibExtUp8 = if ORActive or today < 1 or sf2 < 1 then na else fib_ext_up8;

plot FibExtUp9 = if ORActive or today < 1 or sf2 < 1 then na else fib_ext_up9;

plot FibExtUp10 = if ORActive or today < 1 or sf2 < 1 then na else fib_ext_up10;

plot FibExtUp11 = if ORActive or today < 1 or sf2 < 1 then na else fib_ext_up11;


#

# Formatting:

#

ORH.SetDefaultColor(Color.DARK_GRAY);

ORH.SetStyle(Curve.LONG_DASH);

ORH.SetLineWeight(3);

ORL.SetDefaultColor(Color.DARK_GRAY);

ORL.SetStyle(Curve.LONG_DASH);

ORL.SetLineWeight(3);

FibMid.SetDefaultColor(Color.DARK_GRAY);

FibMid.SetStyle(Curve.SHORT_DASH);

FibMid.SetLineWeight(3);

FibExtUp1.SetDefaultColor(Color.DARK_GRAY);

FibExtUp1.SetStyle(Curve.SHORT_DASH);

FibExtUp1.SetLineWeight(1);

FibExtDown1.SetDefaultColor(Color.DARK_GRAY);

FibExtDown1.SetStyle(Curve.SHORT_DASH);

FibExtDown1.SetLineWeight(1);

FibExtUp2.SetDefaultColor(Color.DARK_GRAY);

FibExtUp2.SetStyle(Curve.SHORT_DASH);

FibExtUp2.SetLineWeight(1);

FibExtDown2.SetDefaultColor(Color.DARK_GRAY);

FibExtDown2.SetStyle(Curve.SHORT_DASH);

FibExtDown2.SetLineWeight(1);

FibExtUp3.SetDefaultColor(Color.DARK_GRAY);

FibExtUp3.SetStyle(Curve.SHORT_DASH);

FibExtUp3.SetLineWeight(1);

FibExtDown3.SetDefaultColor(Color.DARK_GRAY);

FibExtDown3.SetStyle(Curve.SHORT_DASH);

FibExtDown3.SetLineWeight(1);

FibExtUp4.SetDefaultColor(Color.DARK_GRAY);

FibExtUp4.SetStyle(Curve.SHORT_DASH);

FibExtUp4.SetLineWeight(1);

FibExtDown4.SetDefaultColor(Color.DARK_GRAY);

FibExtDown4.SetStyle(Curve.SHORT_DASH);

FibExtDown4.SetLineWeight(1);

FibExtUp5.SetDefaultColor(Color.DARK_GRAY);

FibExtUp5.SetStyle(Curve.SHORT_DASH);

FibExtUp5.SetLineWeight(1);

FibExtDown5.SetDefaultColor(Color.DARK_GRAY);

FibExtDown5.SetStyle(Curve.SHORT_DASH);

FibExtDown5.SetLineWeight(1);

FibExtUp6.SetDefaultColor(Color.DARK_GRAY);

FibExtUp6.SetStyle(Curve.SHORT_DASH);

FibExtUp6.SetLineWeight(1);

FibExtUp7.SetDefaultColor(Color.DARK_GRAY);

FibExtUp7.SetStyle(Curve.SHORT_DASH);

FibExtUp7.SetLineWeight(1);

FibExtUp8.SetDefaultColor(Color.DARK_GRAY);

FibExtUp8.SetStyle(Curve.SHORT_DASH);

FibExtUp8.SetLineWeight(1);

FibExtUp9.SetDefaultColor(Color.DARK_GRAY);

FibExtUp9.SetStyle(Curve.SHORT_DASH);

FibExtUp9.SetLineWeight(1);

FibExtUp10.SetDefaultColor(Color.DARK_GRAY);

FibExtUp10.SetStyle(Curve.SHORT_DASH);

FibExtUp10.SetLineWeight(1);

FibExtUp11.SetDefaultColor(Color.DARK_GRAY);

FibExtUp11.SetStyle(Curve.SHORT_DASH);

FibExtUp11.SetLineWeight(1);

AddCloud(if ShowRangeCloud then ORL else double.nan, ORH, Color.LIGHT_GRAY, Color.LIGHT_GRAY);
 

barbaros

Administrator
Staff member
He is trying to give it a fancy name but it is pretty much a opening range breakout. Some people trade the one hour range, 30minute range, some even trade the 2 minute range.
 

BannonMan85

New member
I'm still on this, just trying to catch up with all the videos and training he did and others who are using it as well. I am still trying to find some different indicators to couple with it. It seems like the best thing so far is to couple it with ICT. Here is version 1.4 of his indicator:

Code:
//@version=5
indicator('DR/IDR V1.4', overlay=true, max_lines_count=500, max_boxes_count=500, max_labels_count=500)
import PineCoders/VisibleChart/4 as PCchart

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TheMas7er and bmistiaen

// Input options
// {
LS0='Solid', LS1='Dashed', LS2='Dotted'
BX0='DR', BX1='IDR'
XL0='Follow Time', XL1='Session End', XL2='ADR End', XL3='ODR End', XL4='RDR End'
STDLT0='Dynamic',STDLT1='Static'
// } Input options

TIMEZONE = 'America/New_York'
ONE_HOUR = 3600*1000
ONE_DAY = 24*ONE_HOUR

// Inputs
// {
var GRP1 = "Time Settings"
//timings
exchangeOffset      = input.int(0,"Exchange Offset (hours)", group=GRP1)
regularTime         = input.session('0930-1030', 'RDR Time', group=GRP1)
regularExtend       = input.session('1030-1600', 'RDR Lines Time', group=GRP1)
afterTime           = input.session('1930-2030', 'ADR Time', group=GRP1)
afterExtend         = input.session('2030-0200', 'ADR Lines Time', group=GRP1)
overnightTime       = input.session('0300-0400', 'ODR Time', group=GRP1)
overnightExtend     = input.session('0400-0830', 'ODR Lines Time', group=GRP1)

var GRP2 = "General Settings"
//lines
showRegular         = input.bool(true, 'Regular',                                 group=GRP2, inline='session',       tooltip='Show Regular and/or After and/or Overnight session')
showAfter           = input.bool(true, 'After',                                   group=GRP2, inline='session')
showOvernight       = input.bool(true, 'Overnight',                               group=GRP2, inline='session')
drlines             = input.bool(true, 'Show DR Lines ?', group=GRP2)
idrlines            = input.bool(true, 'Show IDR Lines ?', group=GRP2)
middledrline        = input.bool(false, 'Show Middle DR Line ?', group=GRP2)
middleidrline       = input.bool(true, 'Show Middle IDR Line ?', group=GRP2)
openline            = input.bool(true, 'Show Opening Line ?',                     group=GRP2, inline='openline',      tooltip='Shows the Opening line of the Defining Range.\n- Extend: Extends the drawing of the Opening line into the RDR/ODR Lines Time.')
extendopLines       = input.bool(true, 'Extend',                                  group=GRP2, inline='openline') // Extend, follow price
extendopLinesType   = input.string(XL1, '', options=[XL0,XL1,XL2,XL3,XL4], group=GRP2, inline='openline')
showBackground      = input.bool(true, 'Show DR/IDR Box ?', group=GRP2)
boxType             = input.string(BX1, 'Box DR or IDR ?', options=[BX0,BX1], group=GRP2)
extenddrLines       = input.bool(true, 'Extend DR Lines ?', group=GRP2)
extendidrLines      = input.bool(true, 'Extend IDR Lines ?', group=GRP2)
showAllHistory      = input.bool(false, 'Show complete history ?', 'Might cause a slight drawing delay when panning/moving/zooming the chart.', group=GRP2)
useBoxColors        = input.bool(false, 'Box color based on open and close', 'If unchecked, it will default to the selected Box Background Color', group=GRP2)
extendToEndOfRDR    = input.bool(false, 'Extend lines of all ranges to end of most recent Regular session?', group=GRP2)
showStdLines                = input.bool(true, 'Show STD Lines ?',                        group=GRP2, inline='stdlines',      tooltip='Shows the Standard Deviation lines in 0.5 IDR range increments.\n- All = Shows all the STD lines on previous sessions.\n- Labels = Show STD level labels.\n- Dropdown = Choose between Dynamic or Static STD lines.')
showStdLinesAll             = input.bool(true, 'All',                                     group=GRP2, inline='stdlines')
showStdLineLabels           = input.bool(true, 'Labels',                                  group=GRP2, inline='stdlines')
stdLineType                 = input.string(STDLT1, '', [STDLT0,STDLT1],                   group=GRP2, inline='stdlines')
stdLineDynamicExtraPos      = input.int(0, 'Dynamic (+)', minval=0,                       group=GRP2, inline='stdlinedynamic', tooltip='Dynamic STD Lines.\nDynamically draw STD lines around price action. Progresses with price.\n- (+) = Number of positive extra levels to draw in addition to the lines that are automatically drawn around price action.\n- (-) = Number of negative extra levels to draw in addition to the lines that are automatically drawn around price action.\n- Auto = Automatically determine number of STD lines that need to be drawn. Follows price action.')
stdLineDynamicExtraNeg      = input.int(0, '(-)',         minval=0,                       group=GRP2, inline='stdlinedynamic')
stdLineDynamicExtraAuto     = input.bool(false, 'Auto',                                   group=GRP2, inline='stdlinedynamic')
stdLineStaticExtraPos       = input.int(10, 'Static (+)',  minval=0,                       group=GRP2, inline='stdlinestatic', tooltip='Static STD Lines.\nDraws a fixed number of STD lines.\n- (+) = Number of positive levels to draw.\n- (-) = Number of negative levels to draw.')
stdLineStaticExtraNeg       = input.int(10, '(-)',         minval=0,                       group=GRP2, inline='stdlinestatic')


var GRP3 = "Styles"
linesWidth          = input.int(1, 'Box And Lines Width ?', minval=1, maxval=4, group=GRP3)
drLineColor         = input.color(color.gray, 'DR Line Color', group=GRP3, inline='drline')
drLineStyle         = input.string(LS0, 'Style', options=[LS0,LS1,LS2], group=GRP3, inline='drline')
idrLineColor        = input.color(color.red, 'IDR Line Color', group=GRP3, inline='idrline')
idrLineStyle        = input.string(LS1, 'Style', options=[LS0,LS1,LS2], group=GRP3, inline='idrline')
middleLineColor     = input.color(color.gray, 'Middle Line Color', group=GRP3, inline='midline')
middleLineStyle     = input.string(LS2, 'Style', options=[LS0,LS1,LS2], group=GRP3, inline='midline')
opLineColor         = input.color(color.green, 'Opening Line',                  group=GRP3, inline='openline',      tooltip='Opening line:\n- Color\n- Style\n- Width')
opLineStyle         = input.string(LS2, '', options=[LS0,LS1,LS2],                group=GRP3, inline='openline')
stdLineColor        = input.color(color.gray, 'STD Lines',                  group=GRP3, inline='stdline',      tooltip='Standard deviation lines:\n- Color\n- Style\n- Width')
stdLineStyle        = input.string(LS2, '', options=[LS0,LS1,LS2],                group=GRP3, inline='stdline')
backgroundColor     = input.color(color.new(color.gray, 75), 'Box Background Color', group=GRP3)
boxBorderSize       = input.int(0, title="Box border size", minval=0, group=GRP3)
upBoxColor          = input.color(color.new(color.green, 85), 'Up box', group=GRP3, inline='upbox')
upBorderColor       = input.color(color.green, 'border', group=GRP3, inline='upbox')
downBoxColor        = input.color(color.new(color.red, 85), 'Down box', group=GRP3, inline='downbox')
downBorderColor     = input.color(color.red, 'border', group=GRP3, inline='downbox')
// } Inputs
 
 
// Constants
// {
exchangeOffsetMS = exchangeOffset * 3600000
// } Constants
 
 
// Variables {
var int     startTime           = na
var int     endTime             = na
var string  currentSession      = na

var line    lowrdrl             = na
var line    highrdrl            = na
var line    lowridrl            = na
var line    highridrl           = na
var line    leftrdrl            = na
var line    rightrdrl           = na
var line    middlerdrl          = na
var line    middleridrl         = na
var line    drLineOpen          = na
var box     bgBox               = na

var line[] stdLines                                 = array.new<line>()
var float[] stdLevels                               = array.new<float>()
var label[] stdLabels                               = array.new<label>()

var float   rdrlow              = na
var float   rdrhigh             = na
var float   ridrlow             = na
var float   ridrhigh            = na
var float   rdrmiddle           = na
var float   ridrmiddle          = na
var float   sessionOpen         = na

var float   regidrlow             = na
var float   regidrhigh            = na
var float   sessionHigh                             = na
var float   sessionLow                              = na
var int     stdLinesStartTime                       = na
var int     stdLinesStopTime                        = na

var bool    use_m5              = false
// } Variables
 
 
// Functions {
f_insession(_session) =>
    not na(time(timeframe.period, _session, TIMEZONE))
  
f_timestrToHM(_timeStr) =>
    var int     hourInt   = na
    var int     minuteInt = na
    if str.length(_timeStr) == 4
        hourInt   := int(str.tonumber(str.substring(_timeStr, 0, 2)))
        minuteInt := int(str.tonumber(str.substring(_timeStr, 2, 4)))
    [hourInt, minuteInt]

f_sessionTime(_session, _timezone=syminfo.timezone, _part) =>
    var int ts = na
    if str.length(_session) == 9 and (_part == 0 or _part == 1)
        arraySessionSplit = str.split(_session, '-')
        timeStrTo          = array.get(arraySessionSplit, _part)
        [hourTo, minuteTo] = f_timestrToHM(timeStrTo)
        ts := timestamp(_timezone, year, month, dayofmonth, hourTo, minuteTo)
    ts

f_sessionStartTime(_session, _timezone=syminfo.timezone) => f_sessionTime(_session, _timezone, 0)
f_sessionStopTime(_session, _timezone=syminfo.timezone)  => f_sessionTime(_session, _timezone, 1)
f_timestamp_to_date(int _ts = na, string _tz = na) => timestamp(_tz, year(_ts, _tz), month(_ts, _tz), dayofmonth(_ts, _tz))

f_lineStyle(_inputOption) =>
    switch(_inputOption)
        LS0 => line.style_solid
        LS1 => line.style_dashed
        LS2 => line.style_dotted
        => line.style_solid

f_newline(_color, _style) => line.new(na, na, na, na, xloc=xloc.bar_time, color=_color, style=_style, width=linesWidth)
f_newdrline()   => f_newline(drLineColor, f_lineStyle(drLineStyle))
f_newidrline()  => f_newline(idrLineColor, f_lineStyle(idrLineStyle))
f_newmdline()   => f_newline(middleLineColor, f_lineStyle(middleLineStyle))
f_newopline()   => f_newline(opLineColor, f_lineStyle(opLineStyle))
f_newstdine()   => f_newline(stdLineColor, f_lineStyle(stdLineStyle))


f_newbox()      => box.new(na, na, na, na, xloc=xloc.bar_time, bgcolor=backgroundColor, border_width=boxBorderSize)
 
f_moveLine(_line, _x1, _y, _x2) => line.set_xy1(_line, _x1 + exchangeOffsetMS, _y), line.set_xy2(_line, _x2 + exchangeOffsetMS, _y), _line

f_movebox(_box, _left, _top, _right, _bottom, _bordercolor, _bgcolor) => box.set_lefttop(_box, _left + exchangeOffsetMS, _top), box.set_rightbottom(_box, _right + exchangeOffsetMS, _bottom), box.set_border_color(_box, _bordercolor), box.set_bgcolor(_box, _bgcolor)

f_newLabel() => label.new(na, na, '', xloc = xloc.bar_time, yloc=yloc.price, style=label.style_label_left, color=color(na), textcolor=stdLineColor)
f_moveLabel(_label, _x, _y, _text) =>
    label.set_xy(_label, _x, _y)
    label.set_text(_label, _text)
    _label

f_drawStdLine(_fromTime, _toTime, _level, float _stdLabelValue=na) =>
    if not na(_level)
        if not array.includes(stdLevels, _level)
            array.push(stdLevels, _level)
            array.push(stdLines, f_moveLine(f_newstdine(), _fromTime, _level, _toTime))
            if showStdLineLabels
                array.push(stdLabels, f_moveLabel(f_newLabel(), _toTime, _level, str.format('{0}',_stdLabelValue)))


f_drawStdLines(_fromTime, _toTime, bool _clear = false) =>
    var float   stdStepFactor   = 0.5
    var float   stdStep         = na
    var float   stdLevel        = na
    var float   stdLabelValue   = na
    var int     nrLevels        = na
    var int     nrLevelsPos     = na
    var int     nrLevelsNeg     = na

    if _clear and not showStdLinesAll and array.size(stdLevels) > 0
        // If we don't need to show all the lines, delete them each time we clear. If we do need to show all the previous lines, don't delete them.
        for tmpIndex = 0 to array.size(stdLines)-1
            line.delete(array.get(stdLines, tmpIndex))
            if showStdLineLabels
                label.delete(array.get(stdLabels, tmpIndex))
    
    if _clear
        array.clear(stdLevels)
        array.clear(stdLines)
        if showStdLineLabels
            array.clear(stdLabels)

    stdStep := math.abs(regidrhigh-regidrlow)  * stdStepFactor

    if stdStep != 0

        switch stdLineType
            STDLT0 =>
                nrLevelsPos := math.ceil(math.max(sessionHigh - regidrhigh, 0) / stdStep) + (stdLineDynamicExtraAuto ? 0 : stdLineDynamicExtraPos)
                nrLevelsNeg := math.ceil(math.max(regidrlow - sessionLow, 0)   / stdStep) + (stdLineDynamicExtraAuto ? 0 : stdLineDynamicExtraNeg)
            STDLT1 =>
                nrLevelsPos := stdLineStaticExtraPos
                nrLevelsNeg := stdLineStaticExtraNeg

        // Positive lines
        if nrLevelsPos >= 1
            for cnt = 1 to nrLevelsPos
                stdLevel      := regidrhigh + (cnt * stdStep)
                stdLabelValue := cnt * stdStepFactor
                f_drawStdLine(_fromTime, _toTime, stdLevel, stdLabelValue)

        // Negative lines
        if nrLevelsNeg >= 1
            for cnt = 1 to nrLevelsNeg
                stdLevel      := regidrlow - (cnt * stdStep)
                stdLabelValue := cnt * (-stdStepFactor)
                f_drawStdLine(_fromTime, _toTime, stdLevel, stdLabelValue)

// } Functions
 
// Use the 5 minute timeframe if the chart timeframe is lower than 5m
if barstate.isfirst
    use_m5 := timeframe.in_seconds() < 300
 
[m5_open, m5_high, m5_low, m5_close] = request.security(syminfo.tickerid, '5', [open, high, low, close], lookahead = barmerge.lookahead_on)
 
open_value  = use_m5 ? m5_open  : open
high_value  = use_m5 ? m5_high  : high
low_value   = use_m5 ? m5_low   : low
close_value = use_m5 ? m5_close : close
 
inRegularSession    = f_insession(regularTime)     and showRegular
inRegularExtend     = f_insession(regularExtend)   and showRegular
inAfterSession      = f_insession(afterTime)       and showAfter
inAfterExtend       = f_insession(afterExtend)     and showAfter
inOvernightSession  = f_insession(overnightTime)   and showOvernight
inOvernightExtend   = f_insession(overnightExtend) and showOvernight

inSession           = inRegularSession or inOvernightSession or inAfterSession
inExtend            = inRegularExtend  or inOvernightExtend  or inAfterExtend

enterSession        = inSession and not inSession[1]
enterExtend         = inExtend  and not inExtend[1]

leaveRegularSession     = not  inRegularSession  and     inRegularSession[1]
enterRegularExtend      =      inRegularExtend   and not inRegularExtend[1]


if timeframe.isintraday and (PCchart.barIsVisible() or not showAllHistory)
    if enterSession
        currentSession := inRegularSession ? regularTime : inOvernightSession ? overnightTime : inAfterSession ? afterTime : na
    else if enterExtend
        currentSession := inRegularExtend ? regularExtend : inOvernightExtend ? overnightExtend : inAfterExtend ? afterExtend : na

    if inSession
 
        // Initialize levels
        if not inSession[1]
            startTime   := time
            sessionOpen := open_value
            rdrhigh     := high_value
            rdrlow      := low_value
            ridrlow     := math.min(open_value, close_value)
            ridrhigh    := math.max(open_value, close_value)

            // Initialize drawing objects
            if showBackground
                bgBox       := f_newbox()
 
            if drlines
                highrdrl    := f_newdrline()
                lowrdrl     := f_newdrline()

            if idrlines
                highridrl   := f_newidrline()
                lowridrl    := f_newidrline()
 
            if middledrline
                middlerdrl  := f_newmdline()
            
            if middleidrline
                middleridrl := f_newmdline()
 
            if openline
                drLineOpen    := f_newopline()

        // Calculate levels
        rdrhigh     := math.max(high_value, rdrhigh)
        rdrlow      := math.min(low_value, rdrlow)
        ridrhigh    := math.max(open_value, close_value, ridrhigh)
        ridrlow     := math.min(open_value, close_value, ridrlow)
        rdrmiddle   := math.avg(rdrhigh, rdrlow)
        ridrmiddle  := math.avg(ridrhigh, ridrlow)

    if leaveRegularSession
        regidrhigh := ridrhigh
        regidrlow  := ridrlow
        if inRegularExtend
            stdLinesStartTime := f_sessionStartTime(regularExtend, TIMEZONE)
            stdLinesStopTime :=  f_sessionStopTime(overnightExtend, TIMEZONE) + ONE_DAY * (dayofweek == dayofweek.friday and syminfo.type != 'crypto' ? 3 : 1)

    if enterRegularExtend
        // Initialize session high/low.
        sessionHigh := high_value
        sessionLow  := low_value

    // Remember high/low since session started. Needed for drawing STD levels. Also keep high low beyond Extend.
    sessionHigh     := math.max(sessionHigh, high_value)
    sessionLow      := math.min(sessionLow,  low_value)

    // Draw objects
    if showBackground and inSession
        boxUp               = close_value > sessionOpen
        boxBorderColor      = useBoxColors ? (boxUp ? upBorderColor : downBorderColor) : backgroundColor
        boxBackgroundColor  = useBoxColors ? (boxUp ? upBoxColor    : downBoxColor)    : backgroundColor
        boxHigh             = boxType==BX0 ? rdrhigh : ridrhigh
        boxLow              = boxType==BX0 ? rdrlow  : ridrlow
        f_movebox(bgBox, startTime, boxHigh, time, boxLow, boxBorderColor, boxBackgroundColor)
 
    if extendToEndOfRDR
        if syminfo.type == 'warrant' or syminfo.type == 'structured' or syminfo.type == 'right'
            endTime := time
        else if time > (timenow - 2 * ONE_DAY) // no need to call functions every bar. Only start checking 2 days ago.
            if f_timestamp_to_date(f_sessionStopTime(currentSession, TIMEZONE), TIMEZONE) == f_timestamp_to_date(timenow, TIMEZONE)  //timenow_date
                endTime := f_sessionStopTime(regularExtend, TIMEZONE)
            else
                endTime := time
        else
            endTime := time
    else
        endTime := time

    if drlines and (inSession or (extenddrLines and inExtend))
        f_moveLine(highrdrl, startTime, rdrhigh, endTime)
        f_moveLine(lowrdrl,  startTime, rdrlow,  endTime)
        if middledrline
            f_moveLine(middlerdrl, startTime, rdrmiddle, endTime)
    
    if idrlines and (inSession or (extendidrLines and inExtend))
        f_moveLine(highridrl, startTime, ridrhigh, endTime)
        f_moveLine(lowridrl,  startTime, ridrlow,  endTime)
        if middleidrline
            f_moveLine(middleridrl, startTime, ridrmiddle, endTime)

    if openline and (inSession or (extendopLines and inExtend))
        f_moveLine(drLineOpen, startTime, sessionOpen, endTime)

    if showStdLines
        f_drawStdLines(stdLinesStartTime, stdLinesStopTime, enterRegularExtend)
 
Top