View Full Version : SampleMACrossover live data vs. historical data
08-26-2008, 12:34 PM
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.
08-26-2008, 01:14 PM
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?
08-26-2008, 01:26 PM
Here are the setting. The executions seem to be happening correctly, however I'm not taking positions (as previously explained).
08-26-2008, 01:43 PM
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.
08-26-2008, 01:44 PM
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.
08-26-2008, 01:53 PM
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?
08-26-2008, 02:06 PM
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.
08-26-2008, 11:29 PM
Or try it on an equity like MSFT or AAPL.
08-28-2008, 02:40 PM
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.
08-28-2008, 11:07 PM
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.
08-29-2008, 11:47 AM
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?
08-29-2008, 12:44 PM
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.
08-29-2008, 01:30 PM
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?
08-29-2008, 02:03 PM
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.
08-29-2008, 02:59 PM
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.
08-29-2008, 03:43 PM
I am coming in late so here is what I suggest.
- On Tuesday reset your sim account via Tools > Options > Simulator
- Run your strategy live for 100 shares
- As soon as the strategy is started it will be in a position either long or short displayed in the Control Center window Strategies tab
- If long, go to the Order tab and submit a market order to buy 100 shares in the Sim101 account, if short sell. This will sync the account position to the strategy position
As soon as you feel the trade data is off, let me know. Please keep in mind that a strategy position is not the same as an account position. More information on that at the link below.