Subject : How do I reference my OmniLanguage script? Posted : 12/2/2008 10:19 AM Post #10673
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.
#PARAM "Periods", 20
Dim fSMA as Single
fSMA = Sum(Close, Periods)
fSMA /= Periods
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.