Very Intriguing VWAP Indicator

J

jack

New member
VIP
I mainly use the indicators recommended on the Swing Arm site, but I have been watching this VWAP one as well and it has been spot on. It is from Trade View. I am not a coder, but if someone would like to code it for TOS, I think you would find it very beneficial.

Thanks for considering

Code:
//@version=4
study("My VWAP Reversal + Pivot Points Standard", overlay=true)
higherTF = input("D", type=input.resolution)
prevCloseHTF = security(syminfo.tickerid, higherTF, close[1], lookahead=true)
prevOpenHTF = security(syminfo.tickerid, higherTF, open[1], lookahead=true)
prevHighHTF = security(syminfo.tickerid, higherTF, high[1], lookahead=true)
prevLowHTF = security(syminfo.tickerid, higherTF, low[1], lookahead=true)

pLevel = (prevHighHTF + prevLowHTF + prevCloseHTF) / 3
//r1Level = pLevel * 2 - prevLowHTF
//s1Level = pLevel * 2 - prevHighHTF

//var line r1Line = na
var line pLine = na
var label pLabel = na
//var line s1Line = na

var float open_price = na
var float high_price = na
var float low_price = na
var float gap_up = na

var label lHigh = na
var label lLow = na
var line PriceLine = na

if pLevel[1] != pLevel
//    line.set_x2(r1Line, bar_index)
    line.set_x2(pLine, bar_index)
//    line.set_x2(s1Line, bar_index)
//    line.set_extend(r1Line, extend.none)
    line.set_extend(pLine, extend.none)
//    line.set_extend(s1Line, extend.none)
//    r1Line := line.new(bar_index, r1Level, bar_index, r1Level, extend=extend.right)
    pLine := line.new(bar_index, pLevel, bar_index, pLevel, color=color.orange, width=3, extend=extend.right)
//    s1Line := line.new(bar_index, s1Level, bar_index, s1Level, extend=extend.right)
//    label.new(bar_index, r1Level, "R1", style=label.style_none)
    pLabel := label.new(bar_index, pLevel, "P", style=label.style_none)
//    label.new(bar_index, s1Level, "S1", style=label.style_none)
    label.delete(pLabel[1])
    line.delete(pLine[1])
    open_price := open
    high_price := high
    low_price := low
    gap_up := open > close [1] ? 1 : 0
    lLow := label.new(bar_index, low, tostring(low), style=label.style_label_up, yloc=yloc.belowbar, color=color.red)
    label.delete(lLow[1])
    lHigh := label.new(bar_index, high, tostring(high), style=label.style_label_down, yloc=yloc.abovebar, color=color.lime)
    label.delete(lHigh[1])
    label.delete(gap_up ? lHigh : lLow)
    PriceLine := line.new(bar_index, gap_up ? low_price : high_price, bar_index, gap_up ? low_price : high_price, color=gap_up ? color.red : color.black, style=line.style_dashed, width=2, extend=extend.right)
    line.delete(PriceLine[1])

if not na(pLine) and line.get_x2(pLine) != bar_index
//    line.set_x2(r1Line, bar_index)
    line.set_x2(pLine, bar_index)
    line.set_x2(PriceLine, bar_index)
//    line.set_x2(s1Line, bar_index)
// END
 

Similar threads

Top