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 |

Above or Below Open Condition for Watchlist Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
FaDirt
Posted : Monday, March 18, 2013 3:11:12 PM
Registered User
Joined: 10/7/2004
Posts: 28

Hi Bruce,

I'm trying to create RealCode for determining if the current price of a stock is above or below its opening price and by how much (in real time). I want to be able to use this condition on any bar interval and also want to have the value reflected as a Watchlist column. Also, if the price is above the open the value or cell in the watchlist would be highlighted in green and if the price is below the open the value would be highlighted in red. I looked in the forum and didn't see any example code that I could use. Any help you can provide would be very much appreciated. Thanks.

-Don (fadirt)

Bruce_L
Posted : Monday, March 18, 2013 3:19:05 PM


Worden Trainer

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

You could try something similar to the following RealCode Indicator:

Plot = 100 * (Price.Last / Price.Open - 1)

RealCode for Real People: Indicators

Once you have create the RealCode Indicator, drag and drop it to the WatchList and select Data Column. Then right-click on the WatchList Column Header and select Properties. You will want to check Apply Positive and Negative Coloring. You can adjust the setting as desired (but don't choose None or it won't actually color anything).

Sortable Columns from Indicators



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
FaDirt
Posted : Wednesday, March 20, 2013 11:38:59 AM
Registered User
Joined: 10/7/2004
Posts: 28

Bruce,

The data values don't see to be giving me what I need. I was looking for how much above or below the open the current price is. The value seem to small.

Also, I like to use the 60 min chart but in Stockfinder the hourly chart is based off the top of the hour and not the bottom of the hour. So the first hourly bar is only 30 minutes. I want to see the hourly chart based off of the 9:30 am market open. So the first 60 min bar would complete at 10:30 am and not 10 am. Anyway to modify this in Stockfinder?

Bruce_L
Posted : Wednesday, March 20, 2013 11:44:32 AM


Worden Trainer

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

You would set the RealCode Condition to Daily. I can assure you that the calculation is correct. Please provide specific examples if you think it is not.

It should be possible to create an Hourly Time Frame that works how you want, but you would need to adjust the Block Diagrams of every parent indicator or create a RealCode Indicator in the Class tab with AutoLoop = False to do so. It would not be a universal Time Frame that would just apply to everything.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
FaDirt
Posted : Wednesday, March 20, 2013 2:57:19 PM
Registered User
Joined: 10/7/2004
Posts: 28

Thanks Bruce...I got the Above/Below Indicator to work. Regarding the Hourly Time Frame, is one method easier than another? Does one method affect the performance more than the other? And can you point me to where I could learn to do what you suggested (adjust Block Diagrams, create RC with Class tab)? Thanks.

Don

Bruce_L
Posted : Wednesday, March 20, 2013 5:05:13 PM


Worden Trainer

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

The RealCode approach is probably simpler at this point.

RealCode for Real People: Indicators

As an example, you could replace everything below the Inherits line in the Class tab of the RealCode Editor for a RealCode Indicator with the following to create a RealCode Indicator for Price History which plots using an Hourly Time Frame that ends at the bottom of the hour instead of the top of the hour.

	Sub New
		AutoLoop = False
	End Sub
	Public Overrides Function Plot() As System.Single
		Dim customSymbol As PriceScripting 
		Dim tf As New MinuteTimeFrameProvider
		tf.NumMins = 30
		customSymbol = PriceData(CurrentSymbol, tf)
		If customSymbol.Bar.Count > 0 Then
			Dim Hourly(3) As Single
			Hourly(0) = customSymbol.Bar.OpenValue(0)
			Hourly(1) = customSymbol.Bar.HighValue(0)
			Hourly(2) = customSymbol.Bar.LowValue(0)
			Hourly(3) = customSymbol.Bar.Value(0)
			For i As Integer = 0 To customSymbol.Bar.Count - 1
				If customSymbol.Bar.DateValue(i).Minute = 30 Then
					Hourly(1) = System.Math.Max(Hourly(1), _
						customSymbol.Bar.HighValue(i))
					Hourly(2) = System.Math.Min(Hourly(2), _
						customSymbol.Bar.LowValue(i))
					Hourly(3) = customSymbol.Bar.Value(i)
				Else
					Hourly(0) = customSymbol.Bar.OpenValue(i)
					Hourly(1) = customSymbol.Bar.HighValue(i)
					Hourly(2) = customSymbol.Bar.LowValue(i)
					Hourly(3) = customSymbol.Bar.Value(i)
				End If
				If customSymbol.Bar.DateValue(i).Minute = 30 OrElse _
					i = customSymbol.Bar.Count - 1 OrElse _
					customSymbol.Bar.DateValue(i).DayOfYear <> _
					customSymbol.Bar.DateValue(i + 1).DayOfYear Then
					AddToOutput(customSymbol.Bar.DateValue(i), _
						Hourly(0), Hourly(1), Hourly(2), Hourly(3))
				End If
			Next
		End If
	End Function
End Class


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