NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > Application Technical Support > Strategy Analyzer

Strategy Analyzer Support for automated system backtesting and optimization using the NinjaTrader Strategy Analyzer.

Reply
 
Thread Tools Display Modes
Old 08-26-2008, 12:34 PM   #1
kermode
Junior Member
 
Join Date: Jul 2008
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default SampleMACrossover live data vs. historical data

Hello,

I'm a beginner so be gentle.

I'm having a problem with the SampleMACrossover strategy that comes with the software. When I backtest this strategy it works fine. It takes a position and closes the previous position everytime the moving average lines cross. When I try this strategy with live data it doesn't seem to work the same. It closes the previous position and doesn't open a new position (it waits until the MA lines cross again to take a new position). Do I have a setting wrong? I'd like to be able to understand the problem before I code my own algorithm.

thanks
kermode is offline  
Reply With Quote
Old 08-26-2008, 01:14 PM   #2
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

When you apply a new strategy, what are your order handling settings?

Can you provide a screen shot of the chart with the executions and MA's on it?
NinjaTrader_Ben is offline  
Reply With Quote
Old 08-26-2008, 01:26 PM   #3
kermode
Junior Member
 
Join Date: Jul 2008
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi Ben,

Here are the setting. The executions seem to be happening correctly, however I'm not taking positions (as previously explained).
Attached Images
File Type: jpg MAStrategy.jpg (66.4 KB, 30 views)
kermode is offline  
Reply With Quote
Old 08-26-2008, 01:43 PM   #4
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

The screen shot is very small so I can hardly make out what is going on, however the executions look right on: previous order closes and a new order in the opposite direction every time the MA's cross.
NinjaTrader_Ben is offline  
Reply With Quote
Old 08-26-2008, 01:44 PM   #5
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

Sorry, screenshot is too small to see anything. Is this by chance the YM on TWS/IB? If so, then there is a bug which will be addressing with next release (~2 weeks) from now.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 08-26-2008, 01:53 PM   #6
kermode
Junior Member
 
Join Date: Jul 2008
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi Ben,

Here's a better look at the settings.

Again the executions look fine. However positions are not being taken everytime the MAs cross. If I'm long/short it'll close that position and then wait until the MA cross again to take a new position. Looking at the executions, a position should be closed everytime the lines cross and a new one should be taken. Correct?
Attached Images
File Type: jpg MAStrategy2.jpg (72.9 KB, 19 views)
kermode is offline  
Reply With Quote
Old 08-26-2008, 02:06 PM   #7
kermode
Junior Member
 
Join Date: Jul 2008
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default

As a matter of fact it is the YM on IB. So if I run the code on the S&P emini it should work correctly? I guess I'll fine out tomorrow morning.

Cheers
kermode is offline  
Reply With Quote
Old 08-26-2008, 11:29 PM   #8
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Or try it on an equity like MSFT or AAPL.
NinjaTrader_Josh is offline  
Reply With Quote
Old 08-28-2008, 02:40 PM   #9
kermode
Junior Member
 
Join Date: Jul 2008
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default

I ran the SampleMAcrossover stragety against the MSFT and I received the same results. If i check the MAIN executions tab it seems to be perfect. However when I check the executions and trades tabs under the Account Performance tab it shows that positions are not being taken consistently.
kermode is offline  
Reply With Quote
Old 08-28-2008, 11:07 PM   #10
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Please post some screenshots of where you think there are discrepancies. The Account Performance tab just reports whatever has happened. If it is seen in executions it is there. You may be applying filters to your account tab. Please don't use filters like account or date.
NinjaTrader_Josh is offline  
Reply With Quote
Old 08-29-2008, 11:47 AM   #11
kermode
Junior Member
 
Join Date: Jul 2008
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default

If you compare the chart to the trades tab you'll see that a LONG position was taken @ 27.41 and closed at 27.47. A short position didn't get taken @ 27.47. Why is that?
Attached Images
File Type: jpg Chart.jpg (85.2 KB, 20 views)
File Type: jpg AccountsTrader.jpg (94.0 KB, 10 views)
kermode is offline  
Reply With Quote
Old 08-29-2008, 12:44 PM   #12
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

After a second look at this, it seems there could be two things causing confusion for you here:

-The MA cross strategy is an always in strategy. NT also tries to pair trades in the trades tab. Because the reporting is started mid signal NT pairs the close of the pre-existing signal with the close of the next signal and the next long signal with the sell short signal. That is why you see this odd pairing.

-Also the trades tab only shows trades. An execution that is still open as a position, like what is shown in your screen shot, would be shown in your executions tab.
NinjaTrader_Ben is offline  
Reply With Quote
Old 08-29-2008, 01:30 PM   #13
kermode
Junior Member
 
Join Date: Jul 2008
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default

That doesn't explain things as I see it.

Please correct me if I'm wrong. The SampleMACrossover it supposed to do the following:

1. When the fast SMA crosses over the slow SMA a LONG position is taken.
2. This position remains open until the slow SMA crosses over the fast SMA.
3. At this point the position is closed ans a new SHORT position is taken. This position will not close until the fast SMA crosses over the slow SMA.

The result should be a list of trades that alternate between LONG and SHORT (or vice versa) as shown be back testing the strategy. As you can see be the list of trades only LONG position are being taken. Thus a trade is being skipped. By watching the Position Tab I can confirm that a position is being taken every other crossover.

How do you explain that?
Attached Images
File Type: jpg Trades2.jpg (87.0 KB, 11 views)
kermode is offline  
Reply With Quote
Old 08-29-2008, 02:03 PM   #14
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

Please generate a report that starts on the same day that you started the strategy (or earlier) and you will see what you want to see.

Starting your report while a trade is open, is causing Closes to be paired with Closes and Buys the be paired with Sells. Please look at the Entry and Exit columns in your screen shot and compare them with a report that is generated before your strategy has an open position.
NinjaTrader_Ben is offline  
Reply With Quote
Old 08-29-2008, 02:59 PM   #15
kermode
Junior Member
 
Join Date: Jul 2008
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default

That doesn't answer my question at all. I realize the ENTRY NAME and EXIT NAME aren't correct. The trades however are. I went long at $27.41 and exited that position at $27.47. I went long again at $27.53 and exited at $27.49. I'm missing a SHORT trade in between. I ran a back test for todays day using the same strategy. The trades are SHORT, LONG, SHORT, LONG etc... With the live data the trades are LONG, LONG, LONG etc...

Try as I might there isn't SHORT trade to be found in the live data.
Attached Images
File Type: jpg MSFTBacktest.jpg (88.1 KB, 13 views)
kermode is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can i connect to Forex.com (live account) and connected to Esignal as historical data Greenmoney21 Connecting 14 06-09-2009 06:17 PM
Simulator data not the same as live data on charts dewurster ATM Strategies (Discretionary Trading) 1 08-11-2008 11:43 AM
Converting replay data to historical data kenzo Miscellaneous Support 1 07-09-2008 11:03 AM
Using historical data for a live strategy tony900hwk Strategy Development 5 06-26-2008 11:27 AM
Live but no historical data Rollins Connecting 2 02-15-2008 11:06 AM


All times are GMT -6. The time now is 05:19 PM.