Platinum Customer
Joined: 1/30/2005 Posts: 135
|
Is RealCode possible the the following?
SQR(ABS((SUM(LOG((H + L + C) / 3) - LOG((H1 + L1 + C1) / 3), 30) - SUM(LOG((H + L + C) / 3) - LOG((H1 + L1 + C1) / 3), 30) ^ 2 / 30) / 30))
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I can reproduce that code, but it isn't standard deviation.
'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:StdDev of Log of Typical
'|******************************************************************
'# SDper = UserInput.Integer = 30
Static Typical As New List(Of Single)
Static LogTyp As New List(Of Single)
Static Sum As Single
If isFirstBar Then
Typical.Clear
LogTyp.Clear
Sum = 0
End If
Typical.Insert(0, (Price.High + Price.Low + Price.Close) / 3)
LogTyp.Insert(0, Math.Log(Typical(0)))
If Typical.Count >= 2 Then
Sum += LogTyp(0) - LogTyp(1)
End If
If Typical.Count >= SDPer Then
Plot = Math.Abs((Sum - Sum ^ 2 / SDper) / SDper) ^ .5
Sum -= LogTyp(SDper - 1) - LogTyp(SDper)
Else
Plot = Single.NaN
End If
If isLastBar Then
Typical.Clear
LogTyp.Clear
Sum = 0
End If
As noted in the VFI (Volume Flow Indicator) topic, it is missing one of the ^ 2 required to make it into a standard deviation formula.
SQR(ABS((SUM((LOG((H + L + C) / 3) - LOG((H1 + L1 + C1) / 3)) ^ 2, 30) - SUM(LOG((H + L + C) / 3) - LOG((H1 + L1 + C1) / 3), 30) ^ 2 / 30) / 30))
When this change is made, the RealCode becomes the following.
'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:StdDev of Log of Typical
'|******************************************************************
'# SDper = UserInput.Integer = 30
Static Typical As New List(Of Single)
Static LogTyp As New List(Of Single)
Static Sum As Single
Static SumSq As Single
If isFirstBar Then
Typical.Clear
LogTyp.Clear
Sum = 0
SumSq = 0
End If
Typical.Insert(0, (Price.High + Price.Low + Price.Close) / 3)
LogTyp.Insert(0, Math.Log(Typical(0)))
If Typical.Count >= 2 Then
Sum += LogTyp(0) - LogTyp(1)
SumSq += (LogTyp(0) - LogTyp(1)) ^ 2
End If
If Typical.Count >= SDPer Then
Plot = Math.Abs((SumSq - Sum ^ 2 / SDper) / SDper) ^ .5
Sum -= LogTyp(SDper - 1) - LogTyp(SDper)
SumSq -= (LogTyp(SDper - 1) - LogTyp(SDper)) ^ 2
Else
Plot = Single.NaN
End If
If isLastBar Then
Typical.Clear
LogTyp.Clear
Sum = 0
SumSq = 0
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Platinum Customer
Joined: 1/30/2005 Posts: 135
|
thanks for your help.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|