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

StdDev Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
maljester
Posted : Friday, January 19, 2018 3:04:37 PM
Platinum Customer 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))

Bruce_L
Posted : Friday, January 19, 2018 3:40:27 PM


Worden Trainer

Joined: 10/7/2004
Posts: 63,458

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
maljester
Posted : Friday, January 19, 2018 3:49:30 PM
Platinum Customer Platinum Customer

Joined: 1/30/2005
Posts: 135

thanks for your help.

Bruce_L
Posted : Friday, January 19, 2018 3:49:46 PM


Worden Trainer

Joined: 10/7/2004
Posts: 63,458

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.