allanster

VAMA Volume Adjusted Moving Average

allanster Wizard 已更新   
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!
發布通知:
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.
發布通知:
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.
發布通知:
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:

發布通知:
Revision 4

Updated for Pine Script v5.

Telegram: t.me/allanster • Website: www.allanster.com

If you wish to buy me a refreshing beverage :)...

LTC (preferred): LTDaAe7nPzbpBhZVT9o5f9f8M3aZSPa46Y

BTC: 13LhkeXBYrRomVAqbXcoLXHuqMk6Mf7G6N
開源腳本

本著真正的TradingView精神,該腳本的作者將其開源發布,以便交易者可以理解和驗證它。為作者喝彩吧!您可以免費使用它,但在出版物中重複使用此代碼受網站規則的約束。 您可以收藏它以在圖表上使用。

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想在圖表上使用此腳本?