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

Custom Index Question Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
strategy123
Posted : Tuesday, August 4, 2009 6:53:59 AM
Registered User
Joined: 12/15/2008
Posts: 17
Is there a way to calculate a custom index where the index applies the filtering rules associated with the chart ?  For example, I may be filtering certain stocks in the active watchlist.. that can change each day.  Those are the stocks I want in the index.

Unless I'm missing something, it doesn't look like SF applies any of the rules associated with the Chart,  instead it  takes whatever watchlist you point it to and creates an index.  

thx.
Bruce_L
Posted : Tuesday, August 4, 2009 10:40:48 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I do not know of a way to do this besides copying the symbols that meet your conditions into a Personal Watchlist. You could use this Personal Watchlist in the Custom Index and then delete its contents and recopy the new filtered list into each day to avoid editing the Custom Index.

Watchlist Basics

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
strategy123
Posted : Tuesday, August 4, 2009 10:58:04 AM
Registered User
Joined: 12/15/2008
Posts: 17
okay.. thx.
Bruce_L
Posted : Tuesday, August 4, 2009 11:01:07 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You're welcome.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
jas0501
Posted : Tuesday, August 4, 2009 2:29:03 PM
Registered User
Joined: 12/31/2005
Posts: 2,499
Here is an idea, untested, that might work with some help from Bruce.

Two components:
1. The selction criteria: CRIT
2. The indicator being used in the index: IND

if you reference CRIT in realcode and then use the values of IND conditionally plotting a duplicate of IND for those that meet the critera, call it DUP, then you could just compose the custom index of DUP. The only issue would be the scaling..

What I mean is if there are 100 possible symbols and only 10 qualify the average custom index would be divided by 100, not 10. The shape would be the same, just the scale would be off. 

If that is an issue you could also create a ratio indicator based on the critera and use it to normailze DUP. In the case of 10 of 100 being used in DUP, the ratio would be 100/10, call it RAT, and you would just create a product indicator of RAT * DUP.

This avoids needing to adjust the watchlist.... I think. 

The tricky part is left out. The skeleton would be something like


'# IND = indicator.whatever
'# CRIT = condition.whateverelse

If lastbar andalso CTR.value = True then
'
' plot all values of IND
'
    ?????????????
end if


So Bruce, how would one accomplish the plot of IND values when lastBar = true?
Bruce_L
Posted : Tuesday, August 4, 2009 3:43:44 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
jas0501,
Custom Indexes appear to only include items in the Index with actual values. This would seem to indicate that you could just output Single.NaN for any symbols you didn't want included in the Custom Index. For example, if I just wanted the to output Price when the Filter was True, the RealCode Indicator would look something like the following:

'# Filt = condition.Filter
If Filt.Value = True Then
    Plot = Price.Last
Else
    Plot = Single.NaN
End If

You could then create a Custom Index that would be built around Prices only on Bars where the Filter Rule was True. I've created a Layout that I think demonstrates that this works (based on a Custom Index of Price lining up with Custom Indexes of Price meeting the Filter multiplied by the number of symbols meeting the Filter added to a Custom Index of Price not meeting the Filter multiplied by the number of symbols not meeting the Filter added together). You should be able to Open the attached Layout directly into a running copy of StockFinder.

Attachments:
Filtered Index Demo.sfLayout - 54 KB, downloaded 469 time(s).



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
jas0501
Posted : Tuesday, August 4, 2009 5:43:22 PM
Registered User
Joined: 12/31/2005
Posts: 2,499
Bruce I haven't looked at your indicator, but from your description is seems that your approach would for each bar compose the cutsom index average on that day. This is cool! My previous post was attempting to compose the custom index of today's condition quaifiers, but basing all previous xutome index bars on the same membership. Tese are very different beasts.

I'm not sure what strategy123 was looking for? Each would have some merit depending on what your are interested in. Both would have the same value for the latest bar.

Bruce_L
Posted : Wednesday, August 5, 2009 10:30:14 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
jas0501,
I would probably use the same basic technique if I wanted to just base the Custom Index on the currently filtered list instead of a filtered list that changes each day. I would just use the last value of the Filter Rule to determine if something should be output or not. The following RealCode is designed to Plot the Closing Price if the last result of the Filter Rule is True and not Plot anything if the last result of the Filter Rule is not True and would go after the inherits line in the Class tab of a RealCode Indicator:

   Sub New
        AutoLoop = False
        '# Filt = condition.Filter
    End Sub
    Public Overrides Function Plot() As System.Single
        If Filt.Value(1 - Filt.Count) = True Then
            For i As Integer = 0 To Price.Bar.Count - 1
                AddToOutput(Price.Bar.DateValue(i), Price.Bar.Value(i))
            Next
        End If
    End Function
End Class

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
BobMc
Posted : Wednesday, August 5, 2009 1:01:41 PM
Registered User
Joined: 10/7/2004
Posts: 816
Wow! You guys are really clever.

Now you've got my mind zooming around (as best it can in the a.m.) looking for the cool application of same - that I couldn't figure out how to do before.

Thanks

Bob Mc
strategy123
Posted : Wednesday, August 5, 2009 1:07:38 PM
Registered User
Joined: 12/15/2008
Posts: 17
Wow.. This all looks really neat.  I'm going to have to think thru this.. not sure I understand it yet... but really appreciate the ideas.     thx again.
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.