Matthew Greenslet
 Idol
    Posts: 2077
Joined: 2/27/2006
User Profile |
OmniLanguage indicators can be referenced in other OmniLanguage Scripts, Color Charts, OmniScan lists, Setups, and Strategy Filters. Your scripts will not show in the list to the right in the formula builder; however, all you need to do to reference your script is to call it by the same name of the file you created. It is important to note that if your script contains and #PARAM statements you MUST pass in the value you want to use for the parameter.
For example I have created a new indicator called MySMA. The code used is as follows.
#Indicator
#PARAM "Periods", 20
Dim fSMA as Single
fSMA = Sum(Close, Periods)
fSMA /= Periods
PlotPrice("SMA", fSMA)
Return fSMA
If I wanted to reference this indicator elsewhere, say a color chart, I would simply type MySMA(15). Notice how I am passing in 15 to tell my color chart rule what periodicity I want to use. Say I added a second parameter to MySMA, perhaps a second periodicity to smooth the SMA. Again I need to tell it what values to use for the parameters so I would call it by typing MySMA(15, 40).
If your script contains no parameters you MUST still use empty parenthesis such as MySMA(). If you do not have the parenthesis at the end, other scripts will view it as a variable and not a function call to your indicator which will result in a compile error telling you MySMA is not defined.
|