I am using this Study
## START STUDY
## Anchored_VWAP_STOPS
## linus, 2014-03-10, v0.1
#hint: VWAP stops anchored off FractalTrader pivots.
#hint n: Lookback period for finding swing highs, lows.
input n = 20;
#hint ticks: Offset VWAP lines by this number of ticks.
input ticks = 2.0;
def bnOK = barNumber() > 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 Double.NaN;
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 Double.NaN;
def PivH = if HH > 0 then HH else Double.NaN;
def PivL = if LL > 0 then LL else Double.NaN;
rec dir = compoundValue(1, if !isNaN(PivL) then 1 else if !isNaN(PivH) then -1 else dir[1], 0);
plot Up = dir crosses above 0;
Up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
Up.SetLineWeight(3);
Up.SetDefaultColor(Color.WHITE);
plot Dn = dir crosses below 0;
Dn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Dn.SetLineWeight(3);
Dn.SetDefaultColor(Color.ORANGE);
def LocH = (high + (tickSize() * ticks)) * volume;
def LocL = (low - (tickSize() * ticks)) * volume;
rec PH;
rec VH;
rec PL;
rec VL;
if Dn {
PH = LocH;
VH = volume;
} else {
PH = compoundValue(1, LocH + PH[1], Double.NaN);
VH = compoundValue(1, volume + VH[1], Double.NaN);
}
if Up {
PL = LocL;
VL = volume;
} else {
PL = compoundValue(1, LocL + PL[1], Double.NaN);
VL = compoundValue(1, volume + VL[1], Double.NaN);
}
plot VwapH = if Dn then Double.NaN else PH / VH;
plot VwapL = if Up then Double.NaN else PL / VL;
VwapH.SetDefaultColor(Color.DARK_RED);
VwapL.SetDefaultColor(Color.DARK_GREEN);
## END STUDY
#Note: /ES 5m chart of the Anchored_VWAP_STOPS study.
I am using this Study, from original post, on 300 Tick Chart of /ES. Based on this study every 20 bars new VWAP should be drawn. This does not happen, and VWAP is just a continues line. The only way to update is to open "Edit Studies" "the Flask" & click on Apply, then new lines are drawn. Any one has any idea how to correct this? Below i put the STUDY & pictures of chart.
## START STUDY
## Anchored_VWAP_STOPS
## linus, 2014-03-10, v0.1
#hint: VWAP stops anchored off FractalTrader pivots.
#hint n: Lookback period for finding swing highs, lows.
input n = 20;
#hint ticks: Offset VWAP lines by this number of ticks.
input ticks = 2.0;
def bnOK = barNumber() > 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 Double.NaN;
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 Double.NaN;
def PivH = if HH > 0 then HH else Double.NaN;
def PivL = if LL > 0 then LL else Double.NaN;
rec dir = compoundValue(1, if !isNaN(PivL) then 1 else if !isNaN(PivH) then -1 else dir[1], 0);
plot Up = dir crosses above 0;
Up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
Up.SetLineWeight(3);
Up.SetDefaultColor(Color.WHITE);
plot Dn = dir crosses below 0;
Dn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Dn.SetLineWeight(3);
Dn.SetDefaultColor(Color.ORANGE);
def LocH = (high + (tickSize() * ticks)) * volume;
def LocL = (low - (tickSize() * ticks)) * volume;
rec PH;
rec VH;
rec PL;
rec VL;
if Dn {
PH = LocH;
VH = volume;
} else {
PH = compoundValue(1, LocH + PH[1], Double.NaN);
VH = compoundValue(1, volume + VH[1], Double.NaN);
}
if Up {
PL = LocL;
VL = volume;
} else {
PL = compoundValue(1, LocL + PL[1], Double.NaN);
VL = compoundValue(1, volume + VL[1], Double.NaN);
}
plot VwapH = if Dn then Double.NaN else PH / VH;
plot VwapL = if Up then Double.NaN else PL / VL;
VwapH.SetDefaultColor(Color.DARK_RED);
VwapL.SetDefaultColor(Color.DARK_GREEN);
## END STUDY
#Note: /ES 5m chart of the Anchored_VWAP_STOPS study.
Image, chart not updating
Image, opening Edit Studies & Apply to update
Image in updated with correct lines
If anyone know how to correct this so VWAP is drawn automatically , please post.