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 |

Average Volume for Swing Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
db
Posted : Monday, February 21, 2011 2:32:25 PM
Platinum Customer Platinum Customer

Joined: 1/30/2005
Posts: 25
Hi Bruce,
I am a failure at real code, but will keep trying to learn from the great examples you guys share.  I would like to calculate the average volume from a swing low to swing high and swing high to swing low.

Swing high definition: H < H1 and also H1 > H2
Swing low definition: L > L1 and also L1 < L2

Example for start count:: If swing low definition is true then start add volume at todays bar(L>L1).  Continue to add volume and average the volume until Swing high becomes true.  The last volume to be added and averaged would be bar H1.  The opposite would occur for the average volume going from swing high to swing low.

The logic is comparing volume against previous upswings and downswings along with upswings to downswings.  Drawbacks are areas of whipsaw, but one cannot control all in life.  Would a indicator like this work better as a class or just code for the indicator?  Much to learn.  If you can do the upswing code for me I will try and adapt that for the downswing average.  That way I can attempt to study the code in depth to continue to learn.  If I fail I will call out uncle, lol.

Thanks
Darrell
Bruce_L
Posted : Monday, February 21, 2011 2:41:30 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
If you want to ouput the Average Volume so Far during the Swing at every Bar:

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Average Volume for Swing
'|******************************************************************
Static Sum As Single
Static Count As Integer
If isFirstBar Then
    Sum = 0
    Count = 0
Else If (Price.High < Price.High(1) AndAlso _
    Price.High(1) > Price.High(2)) OrElse _
    (Price.Low > Price.Low(1) AndAlso _
    Price.Low(1) < Price.Low(2)) Then
    Sum = 0
    Count = 0
End If
Sum += Volume.Value
Count += 1
Plot = Sum / Count

If you only want to output Average Volume when a Swing is identified:

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Average Volume for Swing
'|******************************************************************
Static Sum As Single
Static Count As Integer
If isFirstBar Then
    Sum = 0
    Count = 0
Else If (Price.High < Price.High(1) AndAlso _
    Price.High(1) > Price.High(2)) OrElse _
    (Price.Low > Price.Low(1) AndAlso _
    Price.Low(1) < Price.Low(2)) Then
    AddToOutput(Volume.DateValue, Sum / Count)
    Sum = 0
    Count = 0
End If
Sum += Volume.Value
Count += 1
Plot = Single.NaN

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
db
Posted : Monday, February 21, 2011 2:50:18 PM
Platinum Customer Platinum Customer

Joined: 1/30/2005
Posts: 25
Thanks Bruce.  I worked four or five hours and all I ever managed was crap, so much to study.  Course to learn one gets to do some crap first.

thanks again
db
Bruce_L
Posted : Monday, February 21, 2011 2:53:31 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You're welcome.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
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.