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 |

Days Between Events, Realcode Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
dempsey30338
Posted : Tuesday, January 27, 2015 8:08:49 AM
Registered User
Joined: 12/1/2004
Posts: 105

What would the Realcode be to calculate the number of days between MaxC50 (where it occurred) and the current priice, C?

dempsey30338

Bruce_L
Posted : Tuesday, January 27, 2015 12:38:30 PM


Worden Trainer

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

Plese try the following RealCode Indicator.

RealCode for Real People: Indicators (6:05)

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Bars Since MaxClose
'|******************************************************************
'# Period = UserInput.Integer = 50
If Period >= 2 Then
	Static Value As Single
	Static Count As Integer
	Static Index As Integer
	If CurrentIndex = 0 OrElse Price.Close > Value Then
		Value = Price.Close
		Count = 1
		Index = CurrentIndex
	Else If Value = Price.Close Then
		Count += 1
		Index = CurrentIndex
	End If
	If CurrentIndex >= Period Then
		If Price.Close(Period) = Value Then Count -= 1
		If Count = 0 Then
			Value = Price.Close(Period - 1)
			Count = 1
			Index = CurrentIndex - (Period - 1)
			For i As Integer = Period - 2 To 0 Step -1
				If Price.Close(i) > Value Then
					Value = Price.Close(i)
					Count = 1
					Index = CurrentIndex - i
				Else If Price.Close(i) = Value Then
					Count += 1
					Index = CurrentIndex - i
				End If
			Next
		End If
	End If
	If CurrentIndex >= Period - 1 Then
		Plot = CurrentIndex - Index
	Else
		Plot = Single.NaN
	End If
Else
	Plot = 0
End If


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