Indicator · Pine Script v5 · On the chart

Custom AAVWAP

by ak2k2

Custom AAVWAP is an indicator that automatically calculates and plots three Anchored Volume Weighted Average Price (AVWAP) series directly on the price chart.

View on GitHub

Repaints

GitHub stars5on the repository
Pine versionv5runs as is
Lines of code41
Settings1inputs
LicenceMPL-2.0
Last update3 years ago26 Sep 2023

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

41 lines of Pine Script v5 from Pine-Source-Code/v1-source.pine, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

v1-source.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ak2k2

//@version=5
indicator("Custom_AAVWAP", overlay=true,max_labels_count = 500,max_lines_count = 500, max_bars_back = 2000)
lb = input.int(100,"Lookback (# of Periods)",1, 1000,1)

len = lb
src = hlc3

hi = ta.highest(src,len)
hiOffset = - ta.highestbars(src,len)

lo = ta.lowest(src,len)
loOffset = - ta.lowestbars(src,len)

src_vol = volume
hv = ta.highest(src_vol, len)
hvOffset = -ta.highestbars(src_vol, len)

f_avwap(src, date, plotcolor) =>
    float[]    array_sumSrc = array.new_float( date,na)
    float[]    array_sumVol = array.new_float( date,na)
    // float[]    array_final = array.new_float( date,na)
    if date>0 and array.size(array_sumSrc)>0
        for i=date-1 to 0
            sumSrc = src[i] * volume[i]
            sumVol = volume[i]
            array.set(array_sumSrc,i,sumSrc + sumSrc[1+i])
            array.set(array_sumVol,i,sumVol + sumVol[1+i])
            finalVal=array.sum(array_sumSrc) / array.sum(array_sumVol)
            if barstate.islast
                line.new(bar_index[i+1],finalVal,bar_index[i],finalVal,color=plotcolor)        

ath_dt = bar_index-bar_index[hiOffset]
atl_dt = bar_index-bar_index[loOffset]
athv_dt = bar_index-bar_index[hvOffset]

fh=f_avwap(src, ath_dt, color.red)
fl = f_avwap(src,atl_dt, color.green)
fhv = f_avwap(src,athv_dt, color.aqua)

Overview

Custom AAVWAP locates the highest price, lowest price, and highest volume bars within a user-defined lookback period and anchors dynamic VWAP lines to those points. Users can adjust the lookback length setting to change the historical range evaluated for swing points. Because the anchor points and lines are dynamically drawn based on the current lookback window on the last bar, the plots shift as new bars enter the lookback period.

Details

Published by

ak2k2 on GitHub

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Lookback (# of Periods)int100lb
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Midnight VWAP

by TradersPost
228 stars

The Midnight VWAP indicator calculates and overlays two distinct Volume Weighted Average Price (VWAP) lines on the price chart based on customizable session timeframes. It tracks an overnight or pre-market session alongside regular trading hours, resetting cal

Indicator v6 Moving averagesSessions & time
Updated 3 months ago · None stated GitHub repository of Midnight VWAP
7 stars

This indicator overlays Bollinger Bands on the price chart and fills the area between upper and lower bands using a color based on Cumulative Volume Delta trend. It plots an EMA 9 line and fills between the EMA 9 and Bollinger basis in green or red depending o

Indicator v6 Volatility & bandsVolume
Updated 5 months ago · None stated GitHub repository of Deep Chart + BB (CVD Internal)

IFA-VP Context

by eddiebelaval
7 stars

This indicator plots a fixed lookback Volume Profile alongside 20, 50, and 200 Simple Moving Averages directly on the price chart. It highlights trend changes via moving average crosses and marks Point of Control reactions, High Volume Nodes, and Value Area bo

Indicator v6 VolumeSupport & resistance
Updated 3 months ago · None stated GitHub repository of IFA-VP Context

More Volume scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers