Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 4/19/2008 Posts: 21
|
Is Volume Weighted Moving Average available in StockFinder?
|
|
![](/image.aspx?url=http%3a%2f%2fvideos.worden.com%2fforums%2favatars%2fbruceavatar.gif&width=100&height=100)
![](/images/ranks/WordenWing.gif) Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
A Volume Weighted Moving Average is not one of StockFinder's built in Indicators, but one way to create a Simple Volume Weighted Moving Average of Price as a RealCode Indicator would be:
'# Period = UserInput.Single = 20
Static SumVxP As Single
Static SumV As Single
If CurrentIndex >= Period Then
SumVxP += Price.Last * Volume.Value - _
Price.Last(Period) * Volume.Value(Period)
SumV += Volume.Value - Volume.Value(Period)
Plot = SumVxP / SumV
Else If isFirstBar Then
SumVxP = Price.Last * Volume.Value
SumV = Volume.Value
Plot = Single.NaN
Else
SumVxP += Price.Last * Volume.Value
SumV += Volume.Value
If CurrentIndex = Period - 1 Then
Plot = SumVxP / SumV
Else
Plot = Single.NaN
End If
End If
One way to create an Exponential Volume Weighted Moving Average of Price as a RealCode Indicator would be:
'# Period = UserInput.Single = 20
'# Cumulative
Static EMApXv As Single
Static EMAv As Single
Static sumWeight As Single
Static termRatio As Single
If isFirstBar Then
EMApXv = Price.Last * Volume.Value
EMAv = Volume.Value
sumWeight = termRatio + 1
termRatio = (Period - 1) / (Period + 1)
Else
Dim Weight As Single = 1 / sumWeight
EMApXv = EMApXv * (1 - Weight) + Weight * Price.Last * Volume.Value
EMAv = EMAv * (1 - Weight) + Weight * Volume.Value
sumWeight = sumWeight * termRatio + 1
End If
Plot = EMApXv / EMAv
One way to create a Moving Average of Price that is both Front Weighted and Volume Weighted as a RealCode Indicator would be:
'# Period = UserInput.Integer = 20
Static SlSumVxP As Single
Static SlSumV As Single
Static SumVxP As Single
Static SumV As Single
If CurrentIndex >= Period Then
SlSumVxP += Period * Price.Last * Volume.Value - SumVxP
SlSumV += Period * Volume.Value - SumV
SumVxP += Price.Last * Volume.Value - _
Price.Last(Period) * Volume.Value(Period)
SumV += Volume.Value - Volume.Value(Period)
Plot = SlSumVxP / SlSumV
Else If isFirstBar Then
SlSumVxP = Period * Price.Last * Volume.Value
SlSumV = Period * Volume.Value
SumVxP = Price.Last * Volume.Value
SumV = Volume.Value
Plot = Single.NaN
Else
SlSumVxP += Period * Price.Last * Volume.Value - SumVxP
SlSumV += Period * Volume.Value - SumV
SumVxP += Price.Last * Volume.Value
SumV += Volume.Value
If CurrentIndex = Period - 1 Then
Plot = SlSumVxP / SlSumV
Else
Plot = Single.NaN
End If
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
How can I place VWMA on the price itself rather than seperately.
Thanks
Nimal
|
|
![](/image.aspx?url=http%3a%2f%2fvideos.worden.com%2fforums%2favatars%2fbruceavatar.gif&width=100&height=100)
![](/images/ranks/WordenWing.gif) Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You would need to Drag and Drop the Volume Weighted Moving Average Indicator onto Price History and select Overlay with Price History. This would automatically put it in the same Pane and Scale and Price History.
Another option would be to just Drag and Drop the Volume Weighted Moving Average Indicator into the Price History Pane to get it into the same Pane. If you do this, you will need to right-click on the Volume Weighted Moving Average Indicator and select Scaling | Scale With | Price History to get it into the same Scale however.
Working with Indicators
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
Bruce,
Thank You
|
|
Registered User Joined: 5/5/2010 Posts: 185
|
Bruce,
Can you please add a its a new day line to the code above ( reset at start of day).
"Front weighted and volume weighted"
thanks
|
|
![](/image.aspx?url=http%3a%2f%2fvideos.worden.com%2fforums%2favatars%2fbruceavatar.gif&width=100&height=100)
![](/images/ranks/WordenWing.gif) Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
That is not quite how it works. The algorithm is going to end up being completely different than the moving front and volume weighted moving average.
'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:FVWAP
'|******************************************************************
Static count As Integer
Static sumVxP As Single
Static sumV As Single
If isFirstBar Then
count = 0
sumVxP = Single.NaN
sumV = Single.NaN
Else If Price.DateValue.Day <> Price.DateValue(1).Day Then
count = 1
sumVxP = Volume.Value * Price.Last
sumV = Volume.Value
Else
count += 1
sumVxP += count * Volume.Value * Price.Last
sumV += count * Volume.Value
End If
Plot = sumVxP / sumV
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 5/5/2010 Posts: 185
|
Is it possible to combine the 2 codes, new day (reset) 3 bars (user defined) then front weighted and volume weighted ?
|
|
Guest-1 |