Find the symbol(s) that are in the DataSet the longest time
Author: dansmo
Creation Date: 2/7/2011 2:28 AM
profile picture

dansmo

#1
Hi,

a code of mine needs to be executed on the symbol that was in the dataSet all the time in the test period. Until now I have hard coded that symbol in my code but I´d like to deal with this more flexible. Is there a componnt that already deals with finding that symbol in the selected dataset?

dansmo
profile picture

Eugene

#2
FirstActualBar?
profile picture

dansmo

#3
Hmm, in an evolving watchlist code it happens that symbols do not trade anymore and there wont be any new bars.
I think the code need to have a look at the date of the first and last bar of any symbol and compare that to the selected Data Range. If there are more symbols that fit that criteria the one with the most number of bars should be selected.
This would be a great feature for evolving watchlist codes, since these should be run on the symbol that was in the dataset all the time for the Data Range.
Is there a better way?
profile picture

Cone

#4
Why don't you just look for the symbol that has the oldest starting date AND the newest ending date? You'll only have to look once.

Even easier, just include an index, like the Dow 30 in your DataSet and click on that.
profile picture

dansmo

#5
Like I said before: I have hard coded that symbol at the moment. But I want this to be more flexible.
So I need to have a function that is called at the beginning of the script to get the symbol.

Including an index is not an option since that would need more significant changes to my codes.
profile picture

dansmo

#6
Do you agree that this is the solution?
Would it be possible to add this to Community.Components? A Method that returns the symbol string.
CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).