Profile Picture

Using Other Symbols within a strategy

Posted By mjbennett 4 Years Ago
Message
Posted Thursday November 21 2013
Hi there,

I have been experimenting implementing some trend following strategies and have a question about how best to incorporate an index filter onto my code?

Say I want to trade a basket of stocks from the S&P 500 and I want to use something like SPY as a general trend filter, what would be the easiest way to do this?

I tried OtherSymbols["SPY"] but that only works when the symbol is checked to be tested with but I really don't want this index/etf to be part of the test trades, only as an input.

I tried the new Symbol("SPY) method but got a bit lost as I can't see a nice way to get the ISeries from this new symbol to use as an input in an SMA.

Similarly, would this work for the DEMA indicator to or does that need more than one input to work correctly? Sorry for the dumbass questions, just learning C# after coming from Java and the API for RE is new to me too.

Thanks in advance!
phg
Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)
Posted Friday November 22 2013
I think there is an example in the documentation that will help with this. Look for "QQQQ" under "Multiple Symbols". The process is this: test early under NewBar for the index symbol and 'return' so that symbol is not traded. However, under NewBar for all other symbols you still have access to QQQQ information with "OtherSymbols".

-Pete

See also Yahoo group about applying RE.

Posted Monday December 16 2013
Thanks Pete,

It hardly seems like an elegant solution to start writing in if(xxxx) then return; statements for a symbol you want to filter as your code then starts to become quite brittle and linked to specific symbols.

There is no way to read data in from a symbol not selected when you pass into a strategy?

Could you have your filter symbols in one folder/watchlist and then your trading universe in another and filter that way?
phg
Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)
Posted Tuesday December 17 2013
I can think of a couple of ways to handle this off hand. Don't hard code the index (which BTW is now QQQ not QQQQ), turn it into a variable. One way to set that variable is from a "System Parameter" when you start a strategy. Reading a value(s) in from a text file is another approach and is probably the most flexible -- provides for excluding multiple values. Or you could pop up a message box on strategy start and ask for input -- this may be easiest with the added benefit of providing a 'reminder' that a value(s) is needed dynamically.

Does some mix of these thoughts seem reasonably workable?

-Pete

See also Yahoo group about applying RE.

Posted Tuesday December 17 2013
Hi Pete,

The fileloader or dialogue sound like a good solution, how best to achieve that within the code?
phg
Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)Supreme Being (48,479 reputation)
Posted Wednesday December 18 2013
Here are some pointers to get you started:
- Google '.net message box input'.
-See http://stackoverflow.com/questions/10797774/messagebox-with-input-field
-And http://www.csharp-examples.net/inputbox/ (the form can be done in the designer instead)
-The "Microsoft.VisualBasic.Interaction" approach is simplest.

For a file, google "StreamReader" or more generally "FileStream". (Pay particular attention to how the path to the file is specified.)
http://csharp.net-informations.com/file/csharp-textreader-class.htm


-Pete

See also Yahoo group about applying RE.

Posted Wednesday December 18 2013
Thanks so much Pete!

I'll give this a shot and thanks for your patience.

Merry Xmas when it comes Smile


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems