Matthew Greenslet
 Idol
    Posts: 2077
Joined: 2/27/2006
User Profile |
Q: How do I create an indicator of an indicator?
A:
All of the indicators have a default data set (I.E the o,h,l,c of a each bar or data point in the set). For example: SMA(14) will always be calculated using the close prices from each bar.
You can override this "default data set" with any OL function you like. The programming term for this is an 'overload'. The available overloads for an OmniLanguage function are shown from the 'tool tip'. The tool tip is usually shown as you type, however in you inserted the function from the right menu you can display to tool tip by removing and adding back the opening parentheses in the function.
Trye it with the SMA. Start typing SMA(. Right after you open the parenthesis you will see a pop up that says '1 of 2' SMA(Periods).This tells you that you only need to pass in one variable which would be the periodicity you want to use to calculate the SMA. As in the example above you would just call SMA(14) passing in 14 as the number of periods to use in the calculation.
With the tool tip up if you hit the down arrow you will see the second method which is SMA(Data, Periods). This shows you that you can change the data set that the indicator will look at. You know that H function will reference the high price, L for Low, C for close, O for open and V for volume. You can place any function into the data parameter to change this. So if you wanted a SMA of the volume you would use SMA(V, 14). This would give you a 14 period SMA of calculated on each bar using the volume price for that bar.
You can also use other indicators. For example if you wanted a 20 period EMA of 14 period EMA (For more details see the Smoothed EMA example from Chapter 4 of the Pro user guide under Writing an Indicator, Page 41) you would use EMA(EMA(14), 20). You will notice that I had to pass in the number of parameters (14) for my base EMA. This tells the EMA(20) function to calculate the 20 period EMA on each bar using the value of the 14 period EMA.
[Edited by Matthew Greenslet on 6/2/2008 2:55 PM]
|