=========================================
There're couple of indicators that allow to plot spreads. However,
all of them have significant limitations as to number of legs and mathematical
complexity of expressions one can input. As none of them really
suit my needs I decided to develop a new indicator from scratch that would
overcome these shortcomings. The indicator I've developed allows to include
any number of legs, input any meaningful math. expression and also implements
variety of math. functions.
You can plot up to four different expressions using only one instance
of the indicator. Obviously, you can add as many instances of the indicator on
a chart as you want. The first expression can be plotted using five different
plot types: candlestick, OHLC, HiLo, box and line. The remaining three
expressions can be plotted only as lines.
Examples:
---------
(3*'MSFT'+1.5*'ORCL'+2*'HPQ'+'IBM')/(5*'QQQQ')
('AAPL:Open'+'AMZN:High'+'MSFT:Low'+'IBM:Close')/(12*'QQQQ')
'ES 09-10:BidAskMid$'-'YM 09-10:BidAskMid$'
'$EURCAD:High'/'$EURAUD:Low'
(('NQ 09-10:H'-'NQ 09-10:L')/2.0)/'NQ 09-10:Volume'
'ES 09-10:$Open@1Week'-'ES 09-10:$Close@1Day'
EMA('GLD',20)-EMA('GLD',10)
SMA('SLV',20)[2]-SMA('GLD',10)[1]
('ES 09-10:$'[2]+'ES 09-10:$'[1])/('ES 09-10:$'[0]*2)
BondYield(20110630,20171231,0.0275,0.8272*'ZN 06-11',100,2,1)*100
(1 + LOG10(1) + SQRT(0.5 + 3.5) + 3)/(1+RANDOM(1,5))
Math:
-----
- always use dot(.) to denote decimal places regardless of your
operating system settings or localization (e.g.: 1.23, -0.6, +3.33)
+ - addition
- - subtraction
/ - division
* - multiplication
% - modulus
^ - power
( - left bracket
) - right bracket
Instruments:
------------
- all instrument types are supported (stocks 'MSFT', futures 'ES 09-10',
currencies '$EURUSD', indexes '^VIX')
- instruments don't need to be explicitly added to the chart to be able to
use them in expressions
- instruments must always be enclosed in apostrophes or quotation marks
- instruments, instrument qualifiers and instrument time frames are case
insensitive
- instrument qualifiers are optional, if omitted bar close value is used
- instrument time frames are optional, if omitted time frame of primary
(first) instrument in the chart is used
- 'InstrumentName:Qualifier@TimeFrame'
- 'InstrumentName@TimeFrame:Qualifier'
- 'InstrumentName:Qualifier'
- 'InstrumentName@TimeFrame'
- 'InstrumentName'
Instrument qualifiers:
----------------------
- use 'colon' ( to indicate beginning of instrument qualifier sequence
- use 'dollar sign' ($) to multiply instrument value by instrument point
value that is taken from the Instrument Manager, this qualifier can be
combined with others
- following qualifiers are self explanatory and cannot be combined
with each other:
- O or Open
- H or High
- L or Low
- C or Close - this is default value
- M or Median - calculate as follows: (High + Low) / 2
- T or Typical - calculate as follows: (High + Low + Close) / 3
- W or Weighted - calculate as follows: (High + Low + Close + Close) / 4
- V or Volume
- B or Bid
- A or Ask
- BAM or BidAskMid
Instrument time frames:
-----------------------
- use 'at' (@) to indicate beginning of instrument time frame sequence
- time frame comprises two mandatory components: period value
and period type
- period value is any integer number greater than zero
- period type is any of the following values:
- S or Second
- M or Minute
- D or Day
- W or Week
- Y or Year
- T or Tick
- V or Volume
- R or Range
Bars ago:
---------
- allows to look back in specified data series (instruments or
NinjaTrader functions) and obtain preceding (historical) value
from bar that is processed
- use any integer number greater than or equal to zero to denote
how many bars to look back, 'zero' is default value which referes
to current bar and is usually omitted
- must be enclosed in square brackets and specified behind
instrument names or behind NinjaTrade functions (e.g. 'MSFT'[1],
EMA('AAPL:High', 20)[2], 'GLD'[0] is equivalent to 'GLD')
Functions:
----------
- functions are case insensitive
- unless specified otherwise functions take one argument
- always input dates in the following format: yyyyMMdd (e.g. 31st of December 2010 input as 20101231)
- there are two types of functions available:
1) The indicator built-in functions:
------------------------------------
BondYield - returns the yield on a security that pays periodic interest, requires seven arguments,
this function is useful for calculating implied yields of various interest rate instruments,
as this function duplicates Microsoft Excel function YIELD, please refer to Microsoft Excel help for more details
BondPrice - returns the price per $100 face value of a security that pays periodic interest, requires seven arguments,
as this function duplicates Microsoft Excel function PRICE, please refer to Microsoft Excel help for more details
Random - returns random number within the specified range, requires two arguments
Power - returns number raised to the specified power, requires two arguments
Abs - returns absolute value of the specified number
Sqrt - returns square root of the specified number
Seiling - returns the smallest integer greater than or equal to the specified decimal number
Floor - returns the largest integer less than or equal to the specified decimal number
Round - rounds decimal number to nearest integer
Ln - returns natural logarithm of the specified number
Log10 - returns base-10 logarithm of the specified number
Sin - returns sine of the specified number
Cos - returns cosine of the specified number
Tan - returns tangent of the specified number
ArcSin - returns arcsine of the specified number
ArcCos - returns arccosine of the specified number
ArcTan - returns arctangent of the specified number
2) NinjaTrader functions:
-------------------------
- by NinjaTrader functions are meant all default and custom indicators
- to see a complete list of available NinjaTrader functions
and their arguments, please bring up the indicator properties
window and click on the Functions link
- please note, some NinjaTrader functions may not work properly
when used within the indicator, however most common functions
(e.g. SMA, EMA, RSI) should work without any problems
- all NinjaTrader functions require at least one argument
that is instrument name
If you're missing some feature, have a suggestion or have found a bug,
just leave a message in NT discussion forum. I'll be more than happy
to implement it provided that other users would also benefit.
-UltimateIndicator-
Installation
============
- open up NinjaTrader, go to File -> Utilities -> Import NinjaScript,
navigate to 'zip' installation file and click open,
restart NinjaTrader if prompted to do so
- this indicator requires NinjaTrader 7.0.0.16 or higher
Version history
===============
- detailed version history can be found in file 'readme.txt'
which is included in the 'zip' installation file
Note
====
Originally, I created this thread in NT Version 7 Beta forum here: http://www.ninjatrader.com/support/f...ad.php?t=31382. As NT Version 7 is live now and the Beta forum has been locked I'm reposting it here.
Download
https://rapidshare.com/files/1680910...ion.v0.1.6.zip
Comment