# Advanced Examples for our Formula Editor Part 2

## Dec 13, 2012

In a recent article I showed you some of the magic you can do with our formula editor.  Here are some additional examples.

This is just a sample to show you what’s available.  I want to spark your imagination so you can create your own favorite formula.

#### Above VWAP

([Price]-vwap)/std_20
There are so many possible combinations.  This compares the current price to the VWAP.  Then it uses the 20 day standard deviation to set the scale.  Positive numbers mean that the price is above the VWAP.

#### Earnings Date

([EarningD]>=-1 && [EarningD]<=2)
([EarningD]>=-1 && [EarningD]<=2)??-1
[EarningD]??100
Here are three different ways to find stocks which are reporting earnings soon or recently reported earnings.  I wrote the one on top first, and the one on bottom last.
There are two common problems when looking at earnings.  The first is to convert what you’re thinking (i.e. “next week”) from words into a formula.  Make sure you use the calendar tool that’s built into our config window.  That will make your life a lot easier.
The other issue is null values.  What if a stock is approximately half way between its last report and its next report?  What if a company hasn’t scheduled an earnings report?  What if you’re not looking at a real company at all?  QQQ never reports earnings!  In all of these cases, the value for EarningD will be null.  If you display the earnings date as a column, null will show up as blank.  If you set a minimum or maximum value for these filters, you will not get any stocks where this value is null.
The first version of my filter will report a 1 for stocks which are reporting soon or just reported.  It will report 0 for stocks which will report in a few days or later, and for stocks which reported a few days back or sooner.  But you will still see nulls in the same cases.  Nulls are inconvenient!
My second attempt replaced the nulls with a -1.  It reported a 0 or 1 in the same cases as before.  This was a step in the right direction, but it still wasn’t convenient enough.
My third version looks different, although it solves the same problem.  This is just like the normal earnings date filter, except I got rid of the nulls.  If something was null, we now report 100.  (I.e. way in the future.)  Mathematically, that’s not entirely accurate.  However, this turned out to be very convenient.  If you’re looking for a stock that’s not reporting earning right now, is QQQ really any different from a stock that reported 1 1/2 months ago?

#### Pivot

([Price]-(high_p+low_p+last_price)/3)/[Price]*100
This one isn’t very useful any more.  But it was very important at the time.  We didn’t always have pivots as standard filters.  So I took some time and created the formulas myself.  And I shared these formulas with a few people who asked.  This became so popular that we made these formulas into a standard formula.  A lot of our standard formulas start this way.

#### Big 2 Minute Moves

abs([DUp2])
This reports the absolute value of the move in the last two minutes.  This is especially useful in a top list.  You can sort by this field to see all of the big moves together.  I.e. big down moves and big up moves at the top of the list.

#### Big Price

[Price]*1000000
This was another test.  We were testing what happens when you make your columns too small or your numbers too big.  You may have already noticed, we prefer to write “4,500,000”, but we will write “4.5M” if you don’t have enough space.

#### Stock is Moving Up.

sma_60_8>sma_60_20
This is a very simple binary expression.  It will return 1 if the faster SMA is above the slower SMA, or 0 if it is not.

#### Move Relative to Standard Deviation

[DUp5]/standard_deviation
[DUp10]/standard_deviation
[DUp15]/standard_deviation
[DUp30]/standard_deviation
[DUp30]/[YSD]
These have been very popular in our execution consulting.  Again there are a lot of variations on a theme available to you.  But the OddsMaker just works really well with these formulas.
The last two lines are pretty much the same.  At one time the yearly standard deviation was only available in a custom formula.  That’s why it’s written out in words.  The last line was written later, after we added yearly standard deviation as a standard filter.

#### Coming soon, part 3…

This article is the second of a three part series showing examples of some of the different ways to use the formula editor. If you missed Part 1, you can read it here. The next article will cover some advanced topics and some previously unpublished secrets.