pp classic
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Stanistas

//@version=4
study("highlight overnight")

// Pivot Points
pivotX_open = float(na)
pivotX_open := nz(pivotX_open[1],open)
pivotX_high = float(na)
pivotX_high := nz(pivotX_high[1],high)
pivotX_low = float(na)
pivotX_low := nz(pivotX_low[1],low)

pivotX_prev_open = float(na)
pivotX_prev_open := nz(pivotX_prev_open[1])
pivotX_prev_high = float(na)
pivotX_prev_high := nz(pivotX_prev_high[1])
pivotX_prev_low = float(na)
pivotX_prev_low := nz(pivotX_prev_low[1])
pivotX_prev_close = float(na)
pivotX_prev_close := nz(pivotX_prev_close[1])

pivotXGetCurTF()=>
    result = "1M"
    if timeframe.isintraday
        result := timeframe.multiplier <= 15 ? "1D" : "1W"
    else
        if timeframe.isweekly or timeframe.ismonthly
            result := "12M"
    result

fNeg(value) => value <= 0 ? na : value

pivotX_Interval = time(pivotXGetCurTF())
if pivotX_Interval != pivotX_Interval[1]
    pivotX_prev_open := pivotX_open
    pivotX_prev_close := close[1]
    pivotX_prev_high := pivotX_high
    pivotX_prev_low := pivotX_low

    pivotX_open := open
    pivotX_high := high
    pivotX_low := low
else
    pivotX_high := max(pivotX_high, high)
    pivotX_low := min(pivotX_low, low)

// Classic
pivotX_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_prev_close)/3
plot(fNeg(pivotX_Median + 2*(pivotX_prev_high - pivotX_prev_low)), title = 'Pivot.M.Classic.R3')
plot(fNeg(pivotX_Median + 1*(pivotX_prev_high - pivotX_prev_low)), title = 'Pivot.M.Classic.R2')
plot(fNeg(pivotX_Median * 2 - pivotX_prev_low), title = 'Pivot.M.Classic.R1')
plot(fNeg(pivotX_Median), title = 'Pivot.M.Classic.Middle') 
plot(fNeg(pivotX_Median * 2 - pivotX_prev_high), title = 'Pivot.M.Classic.S1')
plot(fNeg(pivotX_Median - 1*(pivotX_prev_high - pivotX_prev_low)), title = 'Pivot.M.Classic.S2')
plot(fNeg(pivotX_Median - 2*(pivotX_prev_high - pivotX_prev_low)), title = 'Pivot.M.Classic.S3')