OmniTrader Professional Forum - OmniLanguage Frequently Asked Questions
How to Reference Historical Values

^ Top
Matthew Greenslet

Posts: 2077

Joined: 2/27/2006

User Profile
 
Subject : How to Reference Historical Values
Posted : 10/8/2007 4:02 PM
Post #6854

Q: How can I get a historical value of price data or an indicator?

A:

A very important concept when writing indicators, systems, and stops is the ability to reference a historical value of price data or indicators. You can do this in OmniLanguage through the use of a look back parameter appended to the end of any function call. This look back parameter is used in the format of [5]. The number within the brackets is the number of bars back you want to reference, and in this case would be 5 bars back. You can use any number you like (within reason). If you try to look back more than the number of bars on the chart it will return the very first value.

Here are some of the function calls you maybe already familiar with

O - Returns the Open Price
H - Returns the High Price
L - Returns the Low Price
C - Return the Close Price
EMA(14) - Returns the value of a 14 period EMA

Anytime you call a function it will return the most current value unless you use a look back. For example if you want to know the value of yesterdays (assuming a daily chart) 14 period EMA you would use

EMA(14)[1]

This will return the value of the 14 period EMA of 1 bar back.
One example that would make use of historical values would be any crossover system.

http://www.omnitrader.com/omnitrader/proforum/thread-view.asp?threadid=1289&posts=1


https://www.omnitrader.com/currentclients/proforum/thread-view.asp?threadid=1288&posts=1