You can access Indicators through scripting two ways. NOTE: Indicators are READ ONLY. They can be used by scripts, but not changed.


A way to access the indicator so that it performs when the condition is TRUE, is to create a statement like this:


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.


'  When both conditions are TRUE, Go Long on next OPEN

IF sp500Index.shortMovingAverage > sp500Index.longMovingAverage AND
  instrument.shortMovingAverage > instrument.longMovingAverage THEN

   '  Go Long on the Open.
   broker.EnterLongOnOpen( instrument.longMovingAverage )



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.



Calculated Indicators, Creating Indicators, Custom Indicators, Indicator Access, Indicator Reference

See Also:

Data Groups and Types, Indicator Pack 1 Indicators


Edit Time: 9/25/2017 09:09:58 AM

Topic ID#: 383


Created with Help & Manual 7 and styled with Premium Pack Version 2.80 © by EC Software