Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Where could I find math functions in Stock Finder? Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
ALIV68
Posted : Thursday, October 25, 2012 2:38:03 AM
Registered User
Joined: 10/19/2010
Posts: 15

  Hi,

Where could I find math functions? I need to natural logarithm and standard deviation for plotting indicator of History Volatility. I don't find it in new RealCode Indncator.

Thank you.

 

 

Bruce_L
Posted : Thursday, October 25, 2012 9:43:33 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

You are not going to find documentation from us on the available math functions as they are part of Visual Basic .NET in general and not specific to RealCode.

The RealCode Programmers Reference and RealCode API together comprise the documentation of the StockFinder specific elements of RealCode. They have examples of programs, but they aren't intended to teach programming or document Visual Basic .NET as a whole.

The RealCode for Real People: Indicators and Writing Conditions in RealCode videos can also be quite useful in learning RealCode.

There are books, websites and even classes you can take about VB.NET that cover Visual Basic .NET itself. I would search for Visual Basic Math Class to find out more information about what is available and how they are used.

You could create the Historical Volatility on a Daily Chart using the following RealCode Indicator (you can Edit the Indicator to change the Period setting):

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Daily Historical Volatility
'|******************************************************************
'# Period = UserInput.integer = 100
Static sumofsqr As Single
If CurrentIndex >= Period + 1 Then
    sumofsqr += System.Math.Log(Price.Last / Price.Last(1)) ^ 2 - _
        System.Math.Log(Price.Last(Period) / Price.Last(Period + 1)) ^ 2
Else If isFirstBar Then
    sumofsqr = 0
Else
    sumofsqr += System.Math.Log(Price.Last / Price.Last(1)) ^ 2
End If
If CurrentIndex >= Period Then
    Plot = 1600 * ((sumofsqr - _
        (System.Math.Log(Price.Last / Price.Last(Period)) ^ 2) / Period) / Period) ^ .5
Else
    Plot = Single.NaN
End If

You could create the Historical Volatility Ratio on a Daily Chart using the following RealCode Indicator:

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Daily Historical Volatility Ratio
'|******************************************************************
'# ShortHV = UserInput.Integer = 10
'# LongHV = UserInput.Integer = 100
Static Sum(1) As Single
Static Start As Integer
If isFirstBar Then
    Sum(0) = 0
    Sum(1) = 0
    Start = System.Math.Max(ShortHV, LongHV)
Else
    Sum(0) += System.Math.Log(Price.Last / Price.Last(1)) ^ 2
    Sum(1) += System.Math.Log(Price.Last / Price.Last(1)) ^ 2
End If
If CurrentIndex > ShortHV Then Sum(0) -= System.Math.Log(Price.Last(ShortHV) / _
        Price.Last(ShortHV + 1)) ^ 2
If CurrentIndex > LongHV Then Sum(1) -= System.Math.Log(Price.Last(LongHV) / _
        Price.Last(LongHV + 1)) ^ 2
If CurrentIndex >= Start Then
    Plot = ((Sum(0) - (System.Math.Log(Price.Last / Price.Last(ShortHV)) ^ 2) / _
        ShortHV) / ShortHV) ^ .5 / _
        ((Sum(1) - (System.Math.Log(Price.Last / Price.Last(LongHV)) ^ 2) / _
        LongHV) / LongHV) ^ .5
Else
    Plot = Single.NaN
End If



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
ALIV68
Posted : Thursday, October 25, 2012 9:55:26 AM
Registered User
Joined: 10/19/2010
Posts: 15

Thank you very much, Bruce!

You very strong help me. 

May God grant you long life and good health! :)

 

ALIV68
Posted : Thursday, October 25, 2012 11:50:09 AM
Registered User
Joined: 10/19/2010
Posts: 15

 I am sorry, Bruce. Could you add to this code plotting horizontal line of 0.50 yet?

Thank you.

Bruce_L
Posted : Thursday, October 25, 2012 12:22:42 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

Plotting a horizontal line at a particular value for the RealCode Indicator would not be done in the RealCode. You would right-click on the scale for the chart and select Add Horizontal Pointer. Then right-click on the Horizontal Pointer and select Properties to adjust its settings.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
ALIV68
Posted : Thursday, October 25, 2012 5:40:38 PM
Registered User
Joined: 10/19/2010
Posts: 15

1. Might Historical Volatility plot in TC 2000 v.12.2?

2. It would be great if TC 2000 have Visual Basic (VB) language syntax as done in Stock Finder.

ALIV68
Posted : Thursday, October 25, 2012 5:44:53 PM
Registered User
Joined: 10/19/2010
Posts: 15

I am sorry, I should like to say - Could I write cod for plotting indicator of  Historical Volatility in TC 2000 v.12.2?

Bruce_L
Posted : Friday, October 26, 2012 8:38:07 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

QUOTE (ALIV68)
Might Historical Volatility plot in TC 2000 v.12.2?

It is possible to do so, but you need to create a different formula for each period you would want to plot and use it as a Custom PCF Indicator.

Historical Volatility (HV)

It is not possible to just create an adjustable indicator as can be done in StockFinder.

QUOTE (ALIV68)
It would be great if TC 2000 have Visual Basic (VB) language syntax as done in Stock Finder.

I agree. RealCode is what I miss most about StockFinder when using TC2000. Thank you for your suggestion. It has been assigned case number 9129.



-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.