// Condition set 2 Short Entry
if (Closes[1][0] > Opens[1][0]
if (BarsInProgress == 0)
&& MACD(shortmacdfast, 32, 3)[0] <= -.1
&& ToTime(Time[0]) > ToTime(9, 0, 0)
&& ToTime(Time[0]) < ToTime(16, 0, 0))
{ EnterShort(DefaultQuantity, ""); }
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Compile error
Collapse
X
-
Compile error
I added the first line of the code below and now getting a compile error. Trying to add in the condition that the secondary bar has a higher Close than the Open. Then would like the other condtions to be based on the primary bar object. Any idea?
Code:Tags: None
-
Hello Zachj,
Thank you for your post.
This is due to the use of two if statements, try adding your two conditions together.
if ((BarsInProgress == 0) && Closes[1][0] > Opens[1][0] && MACD(shortmacdfast, 32, 3)[0] <= -.1 && ToTime(Time[0]) > ToTime(9, 0, 0) && ToTime(Time[0]) < ToTime(16, 0, 0))
Please let me know if I may be of further assistance.
-
Hello Zachj,
Thank you for your response.
Using Closes you aredefining the bar object you are referencing. Closes[1][0] > Opens[1][0] this is referencing the second bar object no matter the BarsInProgress.
For information on BarsInProgress please visit the following link: http://www.ninjatrader.com/support/h...inprogress.htm
For information on Closes please visit the following link: http://www.ninjatrader.com/support/h...tml?closes.htm
Please let me know if I may be of further assistance.
Comment
-
ok thank you. I didn't think it was working, but I should have had less than instead of greater than. Was experimenting with it not entering short unless the last minute bar was a downbar. Either way didn't help my strategy, that addition brought the net profit down in the backtester by like 4k.
Comment
-
Try the strategy with market replay, which is a tad more realistic as a test. It has been my experience that running Market Replay over the same data set usually returns different results. Usually a strategy that seems historically profitable ends up a loser, but there have been 2 occasions that on a lark, I tried on a strategy that seemed a loser, and Market Replay showed it was profitable. I was so shocked that on both occasions, I repeated the test about 4 times.Originally posted by zachj View Postok thank you. I didn't think it was working, but I should have had less than instead of greater than. Was experimenting with it not entering short unless the last minute bar was a downbar. Either way didn't help my strategy, that addition brought the net profit down in the backtester by like 4k.
Unfortunately, those results were so shocking that I have not yet been brave enough to actually let the computer trade it live. One of these days when I have some money that I truly can afford to lose, I just might try.
Comment
-
How is that gonna work as far as analyzing historical data. Im not sure exactly how the market replay works, but it looks like you have to record data and then you can replay it. But Im testing data over a year and half back, not looking to just analyze a day or two of data that ive recorded.
Comment
-
Depending on what the equity is, NinjaTrader has replay data that you can download. I doubt that it goes as much as one year back though.Originally posted by zachj View PostHow is that gonna work as far as analyzing historical data. Im not sure exactly how the market replay works, but it looks like you have to record data and then you can replay it. But Im testing data over a year and half back, not looking to just analyze a day or two of data that ive recorded.
Comment
-
Well no wonder your stategies were getting different results when using market replay, its not testing a big enough sample size. You have to be out at least a year and a half, from what ive read anyway. Logic would suggest the larger the sample size the more accurately it will reflect the real world.
Comment
-
I have market replay data for more than one year out.Originally posted by zachj View PostWell no wonder your stategies were getting different results when using market replay, its not testing a big enough sample size. You have to be out at least a year and a half, from what ive read anyway. Logic would suggest the larger the sample size the more accurately it will reflect the real world.
Apart from which, market conditions change. Which is why selecting the length of test data for a walk forward test is very much also an art: blanket statements as to that length are somewhat difficult to make or justify.
Also, there are many reasons why backtest results will generally provide a different result from live trading; many of such reasons are detailed in the NT documentation itself. Market Replay is the closest thing to live trading that we have, and it is a good demonstration of how the results can differ markedly between live trading and backtesting. Many statistics books will show that a statistically significant sample size is as little as 8, so 20 or more trades more than illustrates the discrepancy. The point is that many of the backtest trades do not get taken in live trading because of the actual market conditions, at the hard right edge. A larger sample size will not make the trades coincide.Last edited by koganam; 03-12-2012, 06:18 AM.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
574 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment