Hi SleepyZ, Can Anchored VWAP be scanned in real time or is it delayed? can you please show how to scan anchored VWAP?
Yes, after modifying the script by renaming all of the plots as defs and defining a plot scan. As you did not indicate what you wanted in a scan, see an example in code below for one of many that can be done.
Code:#START STUDY #Anchored_VWAPv3 #linus, 2014-03-10, v0.1 #10:24 linus: it carries over the previous pivot's lines for high, low and close. (it plots vwaps of the high, low and close that are reset each time a new pivot is found.) #10:25 linus: i wrote it to experiment with vwap as stops. (the high and low vwaps that can be offset by the ticks input.) #10:25 linus: but it should serve as an example of how to reset the vwaps based on a signal. #10:35 linus: #hint: VWAP stops anchored off fractalTrader pivots. #10:37 linus: the code calculates the pivots as PivH and PivL, and then restarts the high, low and close vwaps when it finds a new pivot. Otherwise it continues to calculate the high, low and close vwaps. #10:37 linus: the dashed vwap plots are the saved from the previous pivot, and the solid vwap plots are since the last pivot. #20220708 Sleepyz used missing logic from Mobius fractal pivots #20230315 Sleepyz modified the VwapH and VwapL off the high/low respective of PivotH/PivotL #20230317 Sleepyz added optional bubbles vs arrows at VwapH/VwapL #hint: VWAP stops anchored off fractalTrader pivots. #hint n: Lookback period for finding swing highs, lows. input n = 20; input showarrows = yes; input showbubbles = yes; #hint ticks: Offset High/Low VWAP lines by this number of ticks. input ticks = 0.0; def bn = BarNumber(); def na = Double.NaN; def bnOK = bn > n; def isHigher = fold i = 1 to n + 1 with p = 1 while p do high > GetValue(high, -i); def HH = if bnOK and isHigher and high == Highest(high, n) then high else na; def isLower = fold j = 1 to n + 1 with q = 1 while q do low < GetValue(low, -j); def LL = if bnOK and isLower and low == Lowest(low, n) then low else na; def PHBar = if !IsNaN(HH) then bn else PHBar[1]; def PLBar = if !IsNaN(LL) then bn else PLBar[1]; def PHL = if !IsNaN(HH) then HH else PHL[1]; def PLL = if !IsNaN(LL) then LL else PLL[1]; def priorPHBar = if PHL != PHL[1] then PHBar[1] else priorPHBar[1]; def priorPLBar = if PLL != PLL[1] then PLBar[1] else priorPLBar[1]; def HighPivots = bn >= HighestAll(priorPHBar); def LowPivots = bn >= HighestAll(priorPLBar); def PivH = if !IsNaN(HH) > 0 then HighPivots else na; def PivL = if !IsNaN(LL) > 0 then LowPivots else na; def Up = bn == PLBar; AddChartBubble(showbubbles and bn == PLBar, low, AsText(low), Color.GREEN, no); def Dn = bn == PHBar; def LocH = (high + (TickSize() * ticks)) * volume; def LocL = (low - (TickSize() * ticks)) * volume; def LocC = close * volume; rec PC; rec VC; rec PC2; rec VC2; rec PH; rec VH; rec PL; rec VL; rec PH2; rec VH2; rec PL2; rec VL2; if Dn or Up { PC = LocC; VC = volume; PC2 = PC[1]; VC2 = VC[1]; } else { PC = CompoundValue(1, LocC + PC[1], na); VC = CompoundValue(1, volume + VC[1], na); PC2 = CompoundValue(1, LocC + PC2[1], na); VC2 = CompoundValue(1, volume + VC2[1], na); } if Dn { PH = LocH; VH = volume; PH2 = PH[1]; VH2 = VH[1]; } else { PH = CompoundValue(1, LocH + PH[1], na); VH = CompoundValue(1, volume + VH[1], na); PH2 = CompoundValue(1, LocH + PH2[1], na); VH2 = CompoundValue(1, volume + VH2[1], na); } if Up { PL = LocL; VL = volume; PL2 = PL[1]; VL2 = VL[1]; } else { PL = CompoundValue(1, LocL + PL[1], na); VL = CompoundValue(1, volume + VL[1], na); PL2 = CompoundValue(1, LocL + PL2[1], na); VL2 = CompoundValue(1, volume + VL2[1], na); } def VwapC = if Dn[-1] or Up[-1] then na else PC / VC; def VwapC2 = if Dn[-1] or Up[-1] then na else PC2 / VC2; def VwapH = if Dn[-1] then na else PH / VH; def VwapL = if Up[-1] then na else PL / VL; def VwapH2 = if Dn[-1] then na else PH2 / VH2; def VwapL2 = if Up[-1] then na else PL2 / VL2; plot scan = close crosses below VwapC;
Last edited: