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

Bars since higher close or lower close Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
sageofhalo
Posted : Tuesday, February 24, 2015 3:35:41 PM
Platinum Customer 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

Bruce_L
Posted : Thursday, February 26, 2015 11:49:06 AM


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
sageofhalo
Posted : Thursday, March 19, 2015 5:56:36 PM
Platinum Customer Platinum Customer

Joined: 2/24/2013
Posts: 16

Thanks looks like that did the trick.

Bruce_L
Posted : Thursday, March 26, 2015 10:47:27 AM


Worden Trainer

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

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.