Matthew Greenslet
 Idol
    Posts: 2077
Joined: 2/27/2006
User Profile |
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
[Edited by Matthew Greenslet on 11/5/2007 1:42 PM]
|