Volume adjusted moving average (VAMA, VMA)
Author: profe9
Creation Date: 2/23/2009 9:12 AM
profile picture

profe9

#1
I am trying to write a strategy for a price break of the VAMA using 16 days as its period time. I am a novice at writing, so I'd appreciated a "beginning to end" formula, if you've got the time.



Here is the basoc formula:

VAMA = (V1 * P1 + V2 * P2 + ... + Vn * Pn) / (V1 + V2 + ... + Vn)

Much appreciation,

Art
profile picture

Eugene

#2
<<so I'd appreciated a "beginning to end" formula>>

Having a clear requirement or a "beginning to end" formula is the prerequisite to any programming. There is no clarity with this VAMA formula:

Volume adjusted moving average
VAMA (Volume Adjusted Moving Average) by Dick Arms

The formula above is not VAMA but belongs to a native Wealth-Lab indicator called VMA. For more information, here is the indicator documentation: VMA

QUOTE:
Calculation
VMA = ( V1 * P1 + V2 * P2 + ... + Vn * Pn ) / ( V1 + V2 + ... + Vn )

where,

P1 = current price
P2 = price one bar ago, etc.
V1 = current volume
V2 = volume one bar ago
n = number of periods/bars

profile picture

profe9

#3
So, then using the VMA formula, could you help me write a program to identify when a stock breaks its 16 day moving average of that indicator?
Thanks.
Art
profile picture

Eugene

#4
Sure but note that you can pretty easily use the Rule wizard for that.

1. Since VMA is already a moving average by itself, do you really want double smoothing? If yes then how do you want it to be smoothed and which period should be used?
2. What about exit conditions?
profile picture

profe9

#5
Sorry I may not have all the jargon down, but what I'd like to do is to identify when the stock price breaks above the VMA using 16 days as the fixed period for that average. I'd like to sell when it breaks below the VMA using the same 16 period. I went into the Rule wizard, but I don't find a rule specific for the VMA.
I hope that helps..............thanks
profile picture

Cone

#6
Only the most popular indicators have customized rules. For those that don't, use the General Indicators rule set. See User Guide: Strategy Window > Strategy Builder > General Rules
profile picture

Eugene

#7
Art, we also have a video illustrating what Robert suggests to you:
Tutorial Video | Indicators | Designing Rule-based Strategies, Combining different Indicators

profile picture

profe9

#8
ok...........the video helps quite a bit. I can see how to get a signal when the indicator crosses the price, but not when the price crosses the indicator. Seems like it shouldn't be difficult. Thanks for your help.
profile picture

Eugene

#9
That condition isn't available as a Rule, however it's a no-brainer in code-based strategy. The breakout condition as we know it doesn't seem to make sense with VMA because it will chop to death. Thererefore I'm including an alternative option to use the CrossOver/CrossUnder functions which is a more logical approach with MAs in general. Hope you get the picture:

CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).