Formula Language Course · Lesson 9 of 9

Exercises: test your MetaSpeak

Time to find out what stuck. Fill in the shortcut tables from memory, then write eight formulas that pull together everything from the previous lessons.

BY DAVID JENYNS REFRESHED AUGUST 2026

Work through these with the Indicator Builder open. Writing the formulas, and watching MetaStock accept or reject them, teaches more than re-reading any lesson.

Fill in the shortcuts

From memory, write the coding shortcut for each item below.

Price array identifierShortcut
Open
High
Low
Close
Volume
Arithmetic operatorShortcut
Division
Multiplication
Addition
Subtraction
Comparison operatorShortcut
Less than
Less than or equal to
Greater than
Greater than or equal to
Equal to
Not equal to

Write the formulas

Some of these questions use the moving average function. If you are not yet comfortable with it, review Lesson 4 first. Complete the following:

  1. The close is greater than the open, and either the volume is greater than 50000 or the turnover (closing price multiplied by the volume) is greater than 100000.
  2. The close is within the top 20% of the period's trading range (i.e. low to high).
  3. The close minus 3%.
  4. A weighted moving average of the closing price which can be modified by the user (hint: you will need the Input function).
  5. The closing price is greater than the 10-period simple moving average of the closing price; the volume is greater than a 10-period simple moving average of the volume; and the 10-period simple moving average of the closing price is greater than the 25-period simple moving average of the closing price. Develop the formula so that all of the '10' values can be easily changed using the variables feature.
  6. If the closing price is greater than its 45-period exponential moving average, plot a 10; if not, plot a -5.
  7. Comment out, but do not remove, C>MOV(C,21,S) from the following formula:
    V>Mov(V,20,S) AND C>O AND C>Mov(C,21,S) AND Ref(V,-1)
  8. The 13-period simple moving average of the closing price is greater than the 21-period simple moving average of the closing price; the close is within the top 5% of the day's trading range (i.e. low to high); and the turnover is greater than $200,000.

Where to next

That wraps up the formula language course. Head back to the course home for the full lesson list, then put your new vocabulary to work in the applied tutorials: building an Average True Range indicator and the On Balance Volume indicator.

MetaStock

Formulas need software to run in

Everything in these lessons works in the free 30-day MetaStock trial: full software, live data, your own watchlist.

Start Your Free 30-Day Trial →

30-DAY TRIAL · FULL VERSION · CANCEL ANYTIME · AFFILIATE LINK, SAME PRICE FOR YOU