Profile Picture

Dynamic Stock Ranking

Posted By Trader Naum 5 Years Ago
Posted Monday August 08 2016
A noob question, perhaps, but I am puzzled. I want to dynamically rank the watchlist under the backtest. I have to do it on NewBar() I think, so on every bar a universe of stocks can be re-ranked based on some criteria. Then I'd like to buy top N stocks from the universe. My problem is that NewBar is called on every symbol. I can calculate a value for each symbol (that value can be used to rank). However, I don't think I can be assured that all other symbols were run, so that I can rank order the universe. It's almost like I need to run the backtest twice - first to calculate ranking values and second time to sort those values. Am I missing something? Thanks!!
Posted Monday August 08 2016
There's a sample system that shows how to do this: Symbol Ranking Sample

Basically, MySystem also has a NewBar method you can override.  The base class version of it will call NewBar() for all SymbolScripts, so if you want to do something after NewBar() has been called for all SymbolScripts, then you can call the base NewBar() in MySystem and then put your logic there.

Posted Monday August 08 2016
Thank you. I love when the system already has capabilities built in, and I don't have to invent a kludge to work around limitations!

Similar Topics

Reading This Topic

2005-2021 © RightEdge Systems