View Full Version : Indexes in Strategy Analyzer
grahamwillsher
11-10-2009, 09:32 AM
Hi,
I know that it is possible to chart indexes within Ninjatrader, as I have an S&P 500 chart (code SP500) which has no problems from Yahoo.
My question is, is it possible to run the strategy Analyzer against an index, as I can find no where to import the index.?
Any help on this matter would be much appreciated.
TIA,
Graham.
NinjaTrader_Josh
11-10-2009, 09:53 AM
To backtest against an index you should try an actually tradeable instrument like the SPY for the SP500.
grahamwillsher
11-10-2009, 10:54 AM
josh,
Thanks for the reply. I can access SPY when drawing a normal chart.
Now for the stupid question, how do I add SPY into the left hand items of the strategy analyzer window?
Graham
NinjaTrader_Josh
11-10-2009, 11:00 AM
You will need to add it to your Instrument List. Please see: http://www.ninjatrader-support.com/HelpGuideV6/AddRemoveFromList.html
grahamwillsher
11-30-2009, 01:48 AM
Hi Josh,
Thanks for the reply below.
I have managed to add the SP500 index to the Instrument manager as per your previous link, but when I run the strategy analyzer I get no results, but when I run it under debug mode I do hit both long and short trades.
I use the coding as follows:
private IOrder entryOrder = null;
entryOrder = ExitShort();
when I have investigated further I find that the 'entryOrder' has a null value, which seems to say that I have done something wrong, but when running the same strategy against the NASDAQ 100 I get results out.
Any ideas where I need to look to find out why no physical trades are produced?
TIA,
Graham.
NinjaTrader_Bertrand
11-30-2009, 04:53 AM
Graham, not sure why you assing an Exit order to the entryOrder IOrder object...is this all the code you use?
To check for the instrument setup (SPY) please run with the default SampleMACrossOver and see if this returns trades as expected.
grahamwillsher
11-30-2009, 07:31 AM
Betrand,
Thanks for the reply, the code was only a sample to show using an IOrder object to capture the result of a EnterShort(), ExitShort() function.
I have run the default SampleMACrossOver against ^SPY and it returns the same results of no trades for the daily period 01/01/2000 to current date. So it seems that I have not got something setup correctly, although the chart shows correctly after the strategy has run, with the MACD crossing over a number of times.
Can you think of anything else that I can check.
TIA,
Graham.
file:///C:/DOCUME%7E1/graham/LOCALS%7E1/Temp/moz-screenshot.pngfile:///C:/DOCUME%7E1/graham/LOCALS%7E1/Temp/moz-screenshot-4.png
file:///C:/DOCUME%7E1/graham/LOCALS%7E1/Temp/moz-screenshot-2.pngfile:///C:/DOCUME%7E1/graham/LOCALS%7E1/Temp/moz-screenshot-3.png
NinjaTrader_Josh
11-30-2009, 07:44 AM
Graham,
SPY should not be denoted as an index. Please remove the ^ notation.
grahamwillsher
12-03-2009, 02:47 PM
Josh,
Sorry about this, but I went back to first principles and created a new instrument list in the instrument manager, then selected index as the type and added the Dow Jones, which was automatically entered as ^DJIA.
When I try and run one of the predefined strategies (SimpleMACrossover) against this index I get no results, but the chart shows clearly with the MA's crossing over, so one would expect a trade to be produced in a 19 year period (I ran it from 01/01/1990 to current date).
Is there something up with running the strategy analyzer against indexes, or more probably, have I missed something?
Any help that you could give would be much appreciated, as I am getting to the hair pulling out point.
TIA.
Graham.
NinjaTrader_Austin
12-03-2009, 04:11 PM
Graham, there is indeed an issue with running the Strategy Analyzer against indicies. The expected behavior is for zero trades to occur because in NT, the indicies don't actually have any information available for trades, like how much $/point, for example.
If you think about it, how exactly would you buy or sell the Dow Jones index? There isn't actually a way to directly trade this index. You'd have to pick an instrument that tracks the DJIA, like the YM futures contract, the DIA ETF, or options even. It just isn't possible to directly buy or sell an index (at least not usually).
The same logic holds for other indicies:
S&P 500 - future (ES), stock/ETF (SPY), or options
Russell 2000 - future (TF), stock/ETF (IWM), and of course, options
In most cases, the best choice for backtesting an index is to just backtest the strategy against the corresponding ETF (DIA, QQQQ, IWM, SPY, etc) because these ETFs track the index better than futures (there are issues with fair value (http://www.programtrading.com/fvalue.htm) and such).
Kim1974
12-06-2009, 04:41 AM
I'd like to be able to backtest on indexes aswell. Not because i want to trade directly in the index but because i want certain criterias to be met in the index before i trade a share from that index (ex.: i would want the SMA(50) to be above the SMA(200) in the index before considering going long in a share in the index. Ofcourse other criterias would have to be met on that specific share too).
So when i construct a new strategy i'd like to be able to make it one the conditions that the index-criterias are met.
Could you please consider to make that option in future upgrades?
NinjaTrader_Ben
12-07-2009, 01:02 AM
Hello,
I believe this is possible. You can make criteria based on indices but you can't trade an indice.