Platinum Customer
Joined: 2/24/2013 Posts: 16
|
Hello,
I'm trying to code an indicator to plot the number of bars since there was a close higher than the current close in the case of an up candle or number of bars since there was a close lower than the current close in the case of a down candle.
I'm pretty new to coding and can't seem to get it to loop and do a count of the number of bars.
Thank you
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Maybe something similar to 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
'|******************************************************************
'#Cumulative
Dim Count As Integer = 0
If Price.Last > Price.Last(1) Then
For i As Integer = 1 To CurrentIndex
Count = CurrentIndex + 1
If Price.Last(i) > Price.Last Then
Count = i
Exit For
End If
Next
Else If Price.Last < Price.Last(1) Then
Count = -CurrentIndex - 1
For i As Integer = 1 To CurrentIndex
If Price.Last(i) < Price.Last Then
Count = -i
Exit For
End If
Next
End If
Plot = Count
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Platinum Customer
Joined: 2/24/2013 Posts: 16
|
Thanks looks like that did the trick.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|