Index

"Index" is a multi-purpose multi-instrument indicator. It can be use to plot a 2 (or more) instrument spread, a total portfolio value, a 2 (or more) instrument pair or basket trade price, a multi-instrument index of your own creation, or even to calculate a major index (mainly useful for demonstration purposes). It works with "CalculateOnBarClose" set to either false (real-time) or true (for lower CPU overhead).

Parameters are:

1) SymbolList: a comma-delimited list of symbols
2) WeightList: a comma-delimited list of weights (1 per symbol; or a single weight (default: 1) for all symbols)
3) Divisor: A number (default: 1) divided into the sum of (symbols x weights)
4) NoOutputWhenMissingInput: (default: false) if true, plot will be blank for any bars which have a missing input; if false, the last known good output will be repeated.
5) OldestDataMinutes: Input is considered missing if older than this many minutes. If set to 0 (default) Input is considered missing if older than 1 bar. In no event will it use data from a prior day (if the symbol hasn't opened yet today, it is considered missing).

The ""Input Series" for the indicator is NOT used in the calculation; it is the "clock" that drives the output, and must be time-based (i.e. minute, day, etc. bars). The Input Series should be an active instrument (no missing bars). If you want to plot this indicator on a non-time-based chart (i.e. volume bars), you need to add a time-based data series to the chart, and select that as the "Input Series" to the indicator. This indicator may be used as input to another indicator, but if so you must press "F5" after adding it to the chart due to NT7 issues.

Usage Examples:

(1) Plot a pair trade spread: Long 3 INTC, Short 7 AMD
SymbolList: INTC,AMD
WeightList: 3,-7
Divisor: 1

(2) Plot the spread between two futures months:
SymbolList: ES 06-11,ES 09-11
WeightList: 1,-1
Divisor: 1

(3) Plot the value of a portfolio: 100 SBUX, 300 ACN, 100 AAPL, 200 CAT, 400 T, 100 GLD
SymbolList: SBUX,ACN,AAPL,CAT,T,GLD
WeightList: 100,300,100,200,400,100
Divisor: 1

Reproducing a major index is not especially useful because index quotes and history are easily available from data providers.

The following examples show how they are created, so you can create your own index that has meaning to you.

(4) Plot the Dow Jones Industrial Average (a price-weighted index)
SymbolList: MMM,AA,AXP,T,BAC,BA,CAT,CVX,CSCO,KO,DD,XOM,GE,HPQ,HD,INTC,IBM,JNJ,JPM,KFT,MCD,MRK,MSFT,PFE,PG,TRV,UTX,VZ,WMT,DIS
WeightList: 1 (DJIA is price weighted, all components have equal weight)
Divisor: 0.132129493 (the Dow Divisor as of 7/2/10, see [url]http://www.cmegroup.com/trading/equity-index/files/djia-history-divisor.pdf[/url])

(5) Plot SOX (a market-cap weighted index, weights are shares outstanding on 2/20/11, shares and divisor are from from [url]https://indexes.nasdaqomx.com/MonthEndFiles.aspx[/url])
SymbolList: ALTR,AMAT,AMD,ATHR,AVGO,BRCM,CREE,CRUS,HITT,INTC,KLAC,LLTC,LRCX,MKSI,MRVL,MU,NETL,NSM,NVDA,NVLS,POWI,RBCN,SNDK,STM,TER,TSM,TXN,VECO,WFR,XLNX
WeightList: 364951315,2060521585,1396802719,146660859,490415275,575686296,196473483,141628229,63130703,1212702808,342283544,392826431,251960161,103124900,
1105594919,1763931357,130849166,490825711,941628062,184777433,57263098,46993684,287133221,153857427,371654361,1191268991,805417714,81755766,465958033,472202863
Divisor: 822180367

Created By kdoren
NinjaTrader Version 7
File Size 11.1 KB
Create Date 04/12/2011
# of Downloads 1851

Importing to NinjaTrader 7 is Easy!

To import your 3rd party app or add-on to NinjaTrader, simply follow these 3 steps:

  1. Download the app or add-on file to your desktop
  2. From the NinjaTrader Control Center window, select the menu File > Utilities > Import NinjaScript
  3. Select the downloaded file from your desktop

Questions?

Visit the NinjaScript File Sharing discussion in the NinjaTrader user forum to interact with fellow traders and the NinjaTrader support team.