Registered User Joined: 4/10/2007 Posts: 38
|
Bruce: I am very pleased with the stability of recent SF5 builds. I thank you again for the code you shared with me to dynamically calculate percent gains from a date in-the-past to the present date.
For the benefit of all, I will post that code at the bottom of this entry.
Can you please post the code required to calculate the price percent gain of closing prices between two selected points in time say for example ... 27 Nov 2009 to 08 Feb 2010 ?
Can you please construct the code in such a way as to generate two dialog boxes which allows the user to simply twiddle the calendar date boxes desired inside the "edit" function in a watchlist column ? This is what
the code below yields.
I continue to believe this type of feature would be valuable as a "built-in" SF5 function. Part of the beauty
of SF5 is it's dynamic & continual updating and ranking of price percent gain data when it is viewed in a watchlist column.
Fellow users, can I get a witness to motivate the SF5 developer team ?
Monte
*User tip: Dragging & dropping a column to a lower window duplicates the column in the lower window.
Subsequently dragging & dropping the new column back up to the top window duplicates it with a different name. This is effectively a "copy column " technique, which doesn't presently exist, but perhaps should.
It would be possible to Drag and Drop the following RealCode Indicator
to the Watchlist to use as a Watchlist Column, but it isn't possible to
save Watchlist Columns in either the current versions of SF4 or SF5
except as part of a Layout (you would still need to adjust the colors
under Properties for the Dragged and Dropped Watchlist Column).
'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 4.9 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:My Indicator
'|******************************************************************
'# BasisDate = UserInput.Date = "12/31/2009"
Static BasisPrice As Single
If isFirstBar Then
BasisPrice = Single.NaN
End If
If Price.DateValue = EndOfDay(BasisDate) Then
BasisPrice = Price.Last
End If
Plot = 100 * (Price.Last / BasisPrice - 1)
Bruce Loebrich
Worden Brothers, Inc.
www.Worden.com
'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 4.9 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Percent Change from Date
'|******************************************************************
'# Cumulative
Static Ref As Integer
If isFirstBar Then
Ref = IndexForDate("3/9/2009")
End If
Plot = 100 * Price.Last / Price.Bar.Value(Ref) - 100
Changing the last line by not multiplying everything by 100 within the
RealCode would allow you to add the % in the formatting and get the
result as a Percent Change in the WatchList Column.
'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 4.9 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Percent Change from Date
'|******************************************************************
'# Cumulative
Static Ref As Integer
If isFirstBar Then
Ref = IndexForDate("3/9/2009")
End If
Plot = Price.Last / Price.Bar.Value(Ref) - 1
|
Registered User Joined: 12/31/2005 Posts: 2,499
|
Using 2 date pointers is the typical way to permit dynamic date range assignment. See
for examples.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
montecarlos,
I believe you are requesting something like the following (for SF5 only):
'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 4.9 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Change between Dates
'|******************************************************************
'# Cumulative
'# StartDate = UserInput.Date = "12/31/2008"
'# EndDate = UserInput.Date = "12/31/2009"
Static Ref(1) As Integer
Static Change As Single
If isFirstBar Then
Ref(0) = Math.Min(IndexForDate(StartDate), IndexForDate(EndDate))
Ref(1) = Math.Max(IndexForDate(StartDate), IndexForDate(EndDate))
Change = Price.Bar.Value(Ref(1)) / Price.Bar.Value(Ref(0)) - 1
End If
Plot = Change
-Bruce Personal Criteria Formulas TC2000 Support Articles
|