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 |

WRB Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
krathod
Posted : Wednesday, March 8, 2017 8:57:44 AM
Registered User
Joined: 10/5/2010
Posts: 67

How to define a condition that the current bar is a median bar in the last 100 bars i.e. it is not a very wide bar not a very narrow bar. Thank you.

Bruce_L
Posted : Wednesday, March 8, 2017 12:06:38 PM


Worden Trainer

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

The following RealCode Indicator has user inputs for the period, bottom percentile and top percentile you want to use to check if the bar is near the median.

If you use the default period of 100 with a bottom percentile of 25 and a top percentile of 75, it should return true if the bar range is in middle 50% of bar ranges over the most recent 100 bars.

'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Bar Range Percentile
'|******************************************************************
'# Period = UserInput.Integer = 100
'# BotPerc = UserInput.Single = 25
'# TopPerc = UserInput.Single = 75
Static range As New List(Of Single)
If isFirstBar Then
	range.Clear
End If
range.Insert(0, Price.High - Price.Low)
If range.Count = Period Then
	Dim rank As Integer
	For i As Integer = 1 To range.Count - 1
		rank += System.Math.Sign(range(0) - range(i))
	Next
	range.RemoveAt(range.Count - 1)
	rank = 100 * rank / range.Count / 2 + 50
	If BotPerc <= rank AndAlso _
		rank <= TopPerc Then
		Pass
	End If
Else
	SetIndexInvalid
End If
If isLastBar Then
	range.Clear
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.