|
Indicator Access |
Top Previous Next |
|
Access You can access Indicators through scripting two ways. NOTE: Indicators are READ ONLY. They can be used by scripts, but not changed.
Using the indicator directly. This will return the indicator for the current instrument:
IF myIndicator = 5 THEN PRINT "It is 5"
Or you can access using the instrument object as follows:
IF instrument.myIndicator = 5 THEN PRINT "It is 5" IF sp500Index.myIndicator = 5 THEN PRINT "It is 5"
Using the instrument '.' syntax is equivalent to using the indicator directly.
You can access indicators of other instrument objects using instrument variables and the '.' syntax. For the following example assume that an instrument variable called "sp500Index" has been created and set to the data for the S&P 500 stock index.
IF sp500Index.shortMovingAverage > sp500Index.longMovingAverage AND instrument.shortMovingAverage > instrument.longMovingAverage THEN
' Go Long on the Open. broker.EnterLongOnOpen( instrument.longMovingAverage )
ENDIF
System Scoped Indicators
To access indicators in other blox of your system, you can set them to System Scoped. In the other block, create an IPV Series variable and check Defined Externally in another Block.
Here is an example:
Now you can use this averageClose variable in the block and the value will be consistent across the whole system. |