PDA

View Full Version : MTF NT7 backtest


Stem1
04-23-2010, 08:39 AM
Hi, if I use the code "Add(PeriodType.Minute, 60) and then reference it with a BarsArray[1] etc the same way I do in NT6.5, in the backtest it enters the first trade and stays in no matter what till the end of the test period. Is there a change in the way this needs to be coded?
Thanks

NinjaTrader_Brett
04-23-2010, 09:27 AM
Stem,

This should work in 7. What are you using for your exit condition as I would check there, also are you using BarsInProgress in your code?

Have you added TraceOrders=True to your Initiliaze method to trace your orders to see what is occuring?

Stem1
04-23-2010, 07:30 PM
Exit condition is profit target or stop loss, which works fine before I add the second timeframe.
I haven't been using "BarsInProgress", as I haven't been using it in NT6.5.
eg; Add(PeriodType.Minute, 60); in the initialize
and SMA(BarsArray[1], 50)[0] > SMA(BarsArray[1], 50)[1] in condition set works in NT6.5 but not in 7.
I tried to add "TraceOrders = Trua;" and then "TraceOrders == True;" in the initialize section of the code but I get the "The name True does not exist" error on both attempts.
Thanks

Stem1
04-24-2010, 01:40 AM
It WAS the missing BarsInProgress. Sorry about that, I need to get more sleep...

Stem1
04-26-2010, 01:40 AM
OK, I added the "if (BarsInProgress ==0) line but N7 still takes the first trade and stays in till the end of test period ignoring the Profit target and Stop loss. On my second machine with N6.5 I have the same code and it performs as expected.
I would still like to know how to get the "trace orders" to work.
Thanks

NinjaTrader_Brett
04-26-2010, 07:05 AM
Stem,

What are you using to set your profit target and your stop loss?

Please see the following guide for TraceOrders.

http://www.ninjatrader.com/support/helpGuides/nt7/traceorders.htm?zoom_highlightsub=trace

Then open the output window by going to Control Center->Tools->Output Window and then run your strategy.

NinjaTrader_Brett
04-26-2010, 11:08 AM
Also, please see this great tip guide on TraceOrder.

http://www.ninjatrader-support2.com/vb/showthread.php?t=3627

Stem1
04-28-2010, 02:00 AM
I use the same PT and SL as with the backtest without the addition of the second time frame.
I just ran a test where I removed the "Add(Per", "BarsInPro" ,"BarsArray" lines from the code an ran a backtest without touching the PT and SL and it performed as expected.
I then add the "Add(PeriodType.Minute, 60);" line without the other two lines and it did the "take the first enty and stay in till end of test period".

NinjaTrader_Brett
04-28-2010, 07:00 AM
Glad to hear. Thanks for posting the fix!

Stem1
04-29-2010, 08:14 AM
That's not the fix, I was describing how I've narrowed the problem down to the writing of the "Add(PeriodType..." line of code.

NinjaTrader_Brett
04-29-2010, 08:28 AM
In this case for me to further assist I would need to take a look at your code. There is something that is missing in regards to running a multi-series strategy since it does work when you add the Multiseries.

Can you please send your strategy to support at ninjatrader dot com and reference this forum post and put attn Brett in the subject line and I will take a quick look to see whats causing this.

Stem1
04-30-2010, 06:55 AM
I just upgraded to beta15 and the problem has gone.
Thanks