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