Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Volume Weighted Moving Average Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
cjamesee
Posted : Thursday, July 16, 2009 10:40:30 PM
Registered User
Joined: 4/19/2008
Posts: 21
Is Volume Weighted Moving Average available in StockFinder?
Bruce_L
Posted : Friday, July 17, 2009 8:59:18 AM


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
nimal
Posted : Monday, May 9, 2011 9:25:33 PM
Registered User
Joined: 2/14/2006
Posts: 117
How can I place VWMA on the price itself rather than seperately.
Thanks
Nimal
Bruce_L
Posted : Tuesday, May 10, 2011 8:47:44 AM


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
nimal
Posted : Tuesday, May 10, 2011 10:07:40 PM
Registered User
Joined: 2/14/2006
Posts: 117
Bruce,
Thank You
caution
Posted : Monday, June 11, 2018 2:14:53 PM
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

 

Bruce_L
Posted : Monday, June 11, 2018 2:47:38 PM


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
caution
Posted : Monday, June 11, 2018 3:24:42 PM
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 ?

Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.