//@version=5 indicator('DR/IDR', overlay=true, max_lines_count=500, max_boxes_count=500, max_labels_count=500) import PineCoders/VisibleChart/4 as PCchart // 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() var float[] stdLevels = array.new() var label[] stdLabels = array.new