How to implement filtering of all stocks by criteria?
Author: maximgl
Creation Date: 2/28/2018 4:34 AM
profile picture

maximgl

#1
Let's say that I run my strategy on a very large set of stocks (whole NASDAQ or NYSE sets) and my strategy flag multiple stocks for purchase. Is it possible to order all these stocks by some parameter (for example Volume on the previous day or some Fundamental parameters, like P/E) and then pick just top 3?
profile picture

Eugene

#2
Add your parameter value to the EntrySignal property (as shown in the QuickRef), then sort by it on the Trades tab.

P.S. Note, however, that due to reason expressed here you might want to rather use the Trades+ tab from the Performance Visualizers library. This offers a different sorting experience.
profile picture

maximgl

#3
Assuming that I want to sort them within my program (not in Trades+ tab) for automated trading, is it possible to do such sorting and selection with the code?
profile picture

Eugene

#4
Of course. For example, that's the premise of so called rotation systems. Run a keyword search by the word "rotation" in this form:

Downloadable Strategies

The key to sorting your signals on a portfolio is to:

1. take control of the loop by DataSetSymbols,
2. SetContext() to a symbol,
3. run your trading logic,
4. RestoreContext() etc.

That's what those systems do to get around Wealth-Lab's design i.e. processing a portfolio backtest on a per symbol basis (in alphabetical order) in Raw Profit mode first, and then the position sizing layer kicks in. Given that this framework is in place the sorting itself is pretty trivial.
profile picture

maximgl

#5
Thank you. These strategies are very good starting points.
profile picture

Eugene

#6
At your service.
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).