OPEN-SOURCE SCRIPT

VAMA Volume Adjusted Moving Average

Telah dikemas kini
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, fidelity.com/learning-center/trading-investing/technical-analysis/technical-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!
Nota Keluaran
Revision 1

Changed Subset mode's Average Volume calculation from using native function to custom function.

Renamed some variables to better describe their roles. Edited some comments to better describe logic behavior. Colorized troubleshooting values for Data Window.
Nota Keluaran
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.
Nota Keluaran
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:

VAMA Volume Adjusted Moving Average Function
Nota Keluaran
Revision 4

Updated for Pine Script v5.
adjustedMoving AveragesTrend AnalysisVAMAVolume

Skrip sumber terbuka

Dalam semangat sebenar TradingView, penulis telah menerbitkan kod Pine ini sebagai sumber terbuka supaya pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara percuma, tetapi penggunaan semula kod dalam penerbitan ini adalah dikawal oleh Peraturan dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Ingin menggunakan skrip ini pada carta?


lux ex tenebris • deuro mea umbra absens • Telegram: t.me/allanster
Juga pada:

Penafian