allanster

VAMA Volume Adjusted Moving Average

allanster Wizard Mis à jour   
Richard Arms' Volume Adjusted Moving Average

Settings:

Inp Avg Vol: Input - Purist method but not intended for live analysis, to retroactively alter MA curve enter Avg Vol from value shown on label into Use Avg Vol field.

Inp Avg Vol: Current - Live method using current volume , to retroactively alter past MA curve toggle any setting back and forth to force recalculation.

Inp Avg Vol: Subset - Similar to Current, but uses a subset rather than all bars for avg vol.

Use Avg Vol - Used for Inp Avg Vol: Input mode. Enter volume from Avg Vol label here after each new bar closes, label will turn green, else red.

Subset Data - Lookback length used for Inp Avg Vol: Subset mode.

VAMA Length - Specified number of volume ratio buckets to be reached.

Volume Incr - Size of volume ratio buckets.

VAMA Source - Price used for volume weighted calculations.

VAMA Strict - Must meet desired volume requirements, even if N bars has to exceed VAMA Length to do it.

Show Avg Vol Label - Displays label on chart of total chart volume.

Notes: VAMA was created by Richard Arms. It utilizes a period length that is based on volume increments rather than time. It is an unusual indicator in that it cannot be used in some platforms in realtime mode as Arms had originally intended. VAMA requires that the average volume first be calculated for the entire chart duration, then that average volume is used to derive the variable adaptive length of the moving average. The consequence of this is that with each new bar, the new average volume alters the moving average period for the entire history. Since Pine scripts evaluate all historical bars only once upon initial script execution, there is no way to automatically shift the previous moving average values retroactively once a new bar has formed. Thus the historical plot of the moving average cannot be updated in realtime, but instead can only plot through previous bar that existed upon load or reinitialization through changing some setting.

Setting Use Avg Vol to Input mode the average volume through previous bar shown in label can be entered (input) into the Inp Avg Vol setting after each new bar closes. Entering this total chart volume forces the script to reevaluate historical bars which in turn allows the historical moving average to update the plot. When using Input mode the color of the label is green when Inp Avg Vol value matches current label value, the label color red signifies Inp Avg Vol value has not been entered or is stale.

Setting Use Avg Vol to Current mode allows the script to correctly calculate and plot the correct moving average upon initial load and the realtime moving average moving forward, but can not retroactively alter the plot of the past moving average unless some change is made in the script settings, such as toggling the Use Avg Vol from Current to some other choice and then back to Current.

Setting Use Avg Vol to Subset mode uses a rolling window of volume data to calculate the average volume and can be used in realtime, but should be noted it is a deviation from Richard Arms' original specification.

VAMA info: "Trading Without Fear" by Richard W Arms, Jr, www.fidelity.com/lea...indicator-guide/vama


NOTICE: This is an example script and not meant to be used as an actual strategy. By using this script or any portion thereof, you acknowledge that you have read and understood that this is for research purposes only and I am not responsible for any financial losses you may incur by using this script!
Notes de version:
Revision 1

Changed Subset mode's Average Volume calculation from using native
sum()
function to custom
sumFrom()
function.

Renamed some variables to better describe their roles. Edited some comments to better describe logic behavior. Colorized troubleshooting values for Data Window.
Notes de version:
Revision 2

Added basic error protection, but some instruments and/or combinations of settings may still error due to the computational expense of using multiple for loops. Changed limit for maximum loops to VAMA Length * 5. Situations where a large number of bars is required to meet volume requirements can result in calculations exceeding 20000ms. These situations may arise when VAMA Length and/or Volume Incr settings are too high, and/or the instrument's liquidity is too low. The typical use range of settings has been tested successfully without error against AAPL, BTCUSD, DOGEUSDT, and EURUSD. These were chosen to cover wide range of price and volume possibilities.
Notes de version:
Revision 3

Added tool tip for label. Disabled all Troubleshooting plots except for ‎VAMA Length and number of ‎volume bars used to satisfy chosen method.

There is a newer and much more efficient version of this indicator for live analysis utilizing a single function with a single for loop here:

Notes de version:
Revision 4

Updated for Pine Script v5.

lux ex tenebris • deuro mea umbra absens • Telegram: t.me/allanster
Script open-source

Dans le véritable esprit de TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par le règlement. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.

Vous voulez utiliser ce script sur un graphique ?