Handling Blank Values

Fellow reader and longtime trader Justin Flynn wrote me recently (shared with permission):

Is there an option of including stocks that have no data showing up on your Top List scans? For example, let’s say I want to filter out on my gap scan all tickers over 500m in market cap. Well if I do that and a stock is not reporting a market cap then that stock will not show up on my Top List. Because of that I often times leave out key filters because I dont want to miss those stocks.

This is a common predicament; luckily, a convenient and powerful way to handle this in Trade-Ideas is to use a Custom Formula.

Here’s how to set it up. In your account, go to Tools, then Formula Editor. That will bring up the Custom Formula editor.

Add a new Custom Formula with the following code:

[MCap] ?? -1

The ?? operator will use the normal value for Market Cap if it exists, but if it’s null it will use the value on the right side of the operator, in this case -1.

Here’s a screenshot showing the custom formula:

This ensures that your custom filter for Market Cap will always have a value and you can use it in your filters as you would any other filter.

Notice I used the label Market Cap with default -1 for the Description field. This ends up in the header anywhere I use this filter and serves as a descriptive reminder of the exact behavior.

Here’s a screenshot of a Top List I just created to demonstrate this concept. Notice MSTY has a blank for the Market Cap field but shows -1 for the custom formula I created.

Of course, this has uses beyond just Market Cap. There are plenty of instances where this comes in quite handy.

Are there other cases where you use this?

FYI, for the developer types on the list, the ?? operator is also known as the null-coalescing operator and is supported in any modern programming language. More info here.