#OVERNIGHT ATR input agg = AggregationPeriod.DAY; input length = 14; input averageType = AverageType.WILDERS; input PlotPreMktLinesHrsPastOpen = yes; def bar = BarNumber(); def nan = Double.NaN; def vHigh = high(period= agg); def vLow = low(period= agg); def vClose = close(period= agg); def PMhrs = RegularTradingStart (GetYYYYMMDD()) > GetTime(); def RMhrs = RegularTradingStart (GetYYYYMMDD()) < GetTime(); def PMStart = RMhrs[1] and PMhrs; def PMclose = CompoundValue(1, if PMStart then vHigh else if PMhrs then Max(vHigh, PMclose[1]) else PMclose[1], 0); def PMHigh = CompoundValue(1, if PMStart then vHigh else if PMhrs then Max(vHigh, PMHigh[1]) else PMHigh[1], 0); def PMLow = CompoundValue(1, if PMStart then vLow else if PMhrs then Min(vLow, PMLow[1]) else PMLow[1], 0); def highBar = if PMhrs and vHigh == PMHigh then bar else nan; def lowBar = if PMhrs and vLow == PMLow then bar else nan; def PMHighBar = if bar == HighestAll(highBar) then PMHigh else PMHighBar[1]; def PMLowBar = if bar == HighestAll(lowBar) then PMLow else PMLowBar[1]; plot PMH = if PlotPreMktLinesHrsPastOpen and PMHighBar != 0 then PMHighBar else nan; plot PML = if PlotPreMktLinesHrsPastOpen and PMLowBar != 0 then PMLowBar else nan; plot PMMid = if PlotPreMktLinesHrsPastOpen and PMHighBar != 0 and PMLowBar != 0 then (PMHighBar + PMLowBar) / 2 else nan; #problem solving stuff def ONATR = MovingAverage(averageType, TrueRange(PMHigh, PMclose, PMLow), length); AddLabel(yes,Round( ONATR )+ ": " );