Call value of VWAP at past candle using getvalue(reference vwap())?


Hi all,

I am trying to set a condition for a plot that "the close must be above the VWAP" in order for the plot to appear. But for some reason I can't fathom, it seems that TOS is unable to use the given candle's VWAP value for checking the condition (maybe it's only using the present VWAP instead of what the VWAP value was at that previous candle?). This is despite that I have tried all of the following:

if ... and close>(reference vwap()) then ...

if ... and close>(getvalue(reference vwap(),0)) then ...

def vwap = reference vwap();
if .... and close>getvalue(vwap,0) then ....

def vwap = getvalue(reference vwap(),0);
if .... and close[0]>vwap[0] then ....

def vwap = getvalue(reference vwap(),0);
if .... and close[0]>getvalue(vwap,0) then ....

Etc. etc. I can't understand why the condition won't work correctly. Am I missing something?

Similar threads