Click here to Login





                                                   Volume Adjusted Moving Average

  0

0
Joshua Laferriere
2019-09-03 08:40:33


I want to write my first formula

How do I access the previous trading day's value?

VAMA is (En1 price x volume) / En1 volume

En1 is the sum of (E) of the past n days including today

So... I would use close, but I'd like a moving average of the past 3 closes and past 3 volumes.

Yes I've been looking in the docs

https://www.quantshare.com/item-1194-prev-previous-value-of-the-same-formula

https://www.quantshare.com/how-341-how-to-create-a-custom-trading-indicator

The problem I have is I don't know what built in accessor functions or variables I have access to.

A wiki with them documented would be nice vs having to jump through these half documented how-to's.

I'm new to this editor. I've only written one function. I like the layout of your site. Please bear with me as I'm getting used to it. I work better with top level wiki's and hyperlinks.

A glossary of all available built in variables and functions would be nice



QuantShare
2019-09-03 14:21:04

  0

Hi,

The previous bar value can be accessed using the "ref" function or using []
Example:
a = ref(close, 1);
a = close[1];

To get the moving average of the volume for the past 3 bars:
a = sma(volume, 3);

The link on how to create a custom trading indicator shows instructions on how to create custom function in c# (not in QS language). This is in case the formula is too complex to be implemented in QS language.

Please also check this QS language introduction:
https://www.quantshare.com/sa-499-quantshare-programming-language-tutorial




Joshua Laferriere
2019-09-06 22:35:53

  0

thank you for all that. I've saved them in a reference file I use now for tutorials

So I've created a 3 period volume adjusted moving average

indicator = ((close * volume)+(ref(close, 1)* ref(volume, 1))+(ref(close, 2)* ref(volume, 2)))/(volume+ref(volume, 1)+ref(volume, 2));

edit: for some reason this isn't including volume. It is only a 3 day moving average of price as when mapped against the candlsticks, it's spot on.

I think I have this correct from the formula here: http://www.periyaruniversity.ac.in/ijcii/issue/Vol6No3Dec2016/D4_PID0365.pdf

https://imgur.com/a/iECHPGM

and saved it as vama.azf and added to indicators and it plotted

https://imgur.com/a/5Bvk9XQ

yay! I'm making progress. I suppose you don't know how I could turn this into a function that would accept any value of n? I suppose I could answer that question myself. I'd like to recursively iterate through each close/volume up to n so I can call vama like vama(3) and have it do 3 periods vs a static 3 each time. I might even modify it to be exponential.

The reason I'm relying on this so heavily is because machine learning likes equally sampled data points (i.e. at specific tradeable units, which time is not). Such as trades by dollar or volume and vama is a great candidate.

See: https://towardsdatascience.com/ai-for-algorithmic-trading-rethinking-bars-labeling-and-stationarity-90a7b626f3e1



No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
Elastic Volume Weighted Moving Average - eVWMA
Multiple Time Frames Trading System - Price / Moving Average Cros...
Mahesh Moving Average
Moving Average Ratio
Market Breadth Indicator: Average On Balance Volume

How-to Lessons
How to create a moving average of an indicator
How to calculate the average of a time series using the money man...
How to change volume bar colors when the price closes down
How to create trading rules based on Put and Call volume data
How to create volume bar charts

Related Forum Threads
Average Volume
delay in moving average
Rising moving average
Displaced moving average
coding a moving average

Blog Posts
Custom Indicator: Moving average spread
Trading System: Moving average crossover and few others buy and s...
Different Types of Trading Indicators: Trend, Momentum, Volatilit...
Trend Following and Moving Averages
Using Average True Range to Measure Intraday Volatility









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.