Registered User Joined: 10/7/2004 Posts: 16
|
I cannot find Historical Volatility as an indicator.
I need to use this, with a user-settable input. (but typically 100)
I also need to be able to do an Historical Volatility ratio plot; typically the 6/100.
I note that Bruce L dealt with these issues before for Telechart, so I expected they'd be built into StockFinder.
Thanks.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You could create a Daily Historical Volatility using the following RealCode Indicator:
'# 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 a Daily Historical Volatility Ratio using the following RealCode Indicator:
'# ShortHV = UserInput.Integer = 6
'# LongHV = UserInput.Integer = 100
Static Sum(1) As Single
If isFirstBar Then
Sum(0) = 0
Sum(1) = 0
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 >= 100 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
|