Anchored VWAP 20 perioder, high och low-kurva.
staplar:=20
senaste_high=gt(h,hhv(aref(h,1),staplar))
senaste_low=lt(l,llv(aref(l,1),staplar))
market_open=not(eqv(int(ref(d,1)),int(d)))
periods_h=topbars(senaste_high,staplar,1)
periods_l=topbars(senaste_low,staplar,1)
price_mult_vol_h=mult(h,v)
price_mult_vol_l=mult(l,v)
cumulative_total_h=sum(price_mult_vol_h,periods_h:staplar)
cumulative_total_l=sum(price_mult_vol_l,periods_l:staplar)
cumulative_vol_h=sum(v,periods_h:staplar)
cumulative_vol_l=sum(v,periods_l:staplar)
vwap_h=div(cumulative_total_h,cumulative_vol_h)
vwap_l=div(cumulative_total_l,cumulative_vol_l)
draw(vwap_h,2,rqbw)
draw(vwap_l,3,dgqbw)
add(0,0)
staplar:=20
senaste_high=gt(h,hhv(aref(h,1),staplar))
senaste_low=lt(l,llv(aref(l,1),staplar))
market_open=not(eqv(int(ref(d,1)),int(d)))
periods_h=topbars(senaste_high,staplar,1)
periods_l=topbars(senaste_low,staplar,1)
price_mult_vol_h=mult(h,v)
price_mult_vol_l=mult(l,v)
cumulative_total_h=sum(price_mult_vol_h,periods_h:staplar)
cumulative_total_l=sum(price_mult_vol_l,periods_l:staplar)
cumulative_vol_h=sum(v,periods_h:staplar)
cumulative_vol_l=sum(v,periods_l:staplar)
vwap_h=div(cumulative_total_h,cumulative_vol_h)
vwap_l=div(cumulative_total_l,cumulative_vol_l)
draw(vwap_h,2,rqbw)
draw(vwap_l,3,dgqbw)
add(0,0)