Syntax/Study Examples
Previous  Top  Next

These instructions are for entering and providing appropriate input for a very basic expression that might be entered or selected from the menu as needed.

The Basics:

When you select a study from the pop-up Interpreted Studies Library, an expression line displays in the top window of the Code Editor Form:


The example above shows the C(0) subroutine as chosen from the menu. You may type the expression if you prefer. Whether you type the expression or select it from a menu, you still get C(0) in the top window.

The "C" here represents the Closing value of each issue in your scan and for a chart. The needed parameter will identify the desired day. Your input will indicate how far the date should be removed from the current (most recent) update. For today's close, use the integer zero (0). For the previous close, enter 1, etc..

Therefore, to add a MarketScanner column named C(0), which contains the closing value of each stock for the last date available, you would complete the expression as: C(0).

Click the [Run] button (which becomes enabled once there is an expression) to run the program. Go ahead and try it!

More Examples

For another example, if you enter C(5) and click [OK], then the new column would hold the closing price for each stock five days back (one week ago).

It is not uncommon for the MarketScanner to display an error message when it tries to evaluate an expression such as this because there is often a new issue that does not yet have 6 full days of history. The advanced method of dealing with this is to write your expression so it returns blank for stocks which do not have enough history. The simple way is to click the Options menu, click "Scan DB Options" and then choose the "Exclude new issues..." option. Why don't you go ahead and do that now?

For now, the data you can get is O(x) the open x days ago, H(x) the high x days ago, L(x) the low x days ago, C(x) the close x days ago, V(x) the volume x days ago and I(x) the open interest x days ago (for commodities). Using just these 5 or six references, we can do a lot.

Here are some of the functions that are common to all modes:
getNumDays, getOpen, getHigh, getLow, getClose, getVolume, O, H, L, C, V and I.

If you wanted to display in MarketScanner the (close – open)/((high+low)/2), then in all Language Modes you can enter the expression (C(0) - O(0))/((H(0) + L(0))/2), and click [Run].


This works well for writing or selecting simple expressions. When expressions are typed into the upper window, you must re-enter the equation every time. Therefore, only short simple expressions are well suited to this method. For example, adding a column with the close C(0) is a typical usage.

The other limitation to this method is that often you want to apply a moving average or use certain columns from an existing study, which could be rather involved. A better solution is to write your indicator as a persistent (permanently saved) function.