Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Same strategy, different ninjascript, different results
Collapse
X
-
-
Nice eye. I've caught those before -- but was on my Samsung Galaxy Note 3 trying to figure this out at the time.Originally posted by bltdavid View PostThat's because the two pieces of code are not the same.
Remove the semi-colons from the end of the conditionals of all your if statements.
.
But the one still has rsi[0], and the other script is RSI(2, 0)[0]. (looking at the original green/red code posting).
I haven't tested - but I'm not sure that would return the same exact results.
Comment
-
-
Originally posted by NGorodzhiy View PostI do. CrossAbove and CrossBelow is his version of ">" and "<".
As stated already, CrossAbove is like ">" but it's actually more than that. (Make no mistake, it is definitely not the same as ">").
Let's examine how they are different.
If you say,
it's obviously "true" for all bars where Close[0] is greater than the value returned by SMA(20)[0]. Makes sense, right?Code:if (Close[0] > SMA(20)[0]) { }
But CrossAbove() does an additional check, and thus is not the same as the plain vanilla ">" check by itself. This additional check is where CrossAbove's lookback argument comes into play.
Consider that this code,
is equivalent to this expanded version,Code:if (CrossAbove(Close, SMA(20), 1)) { }
because the point of CrossAbove is to return "true" only on the bar where the cross over actually happens.Code:if (Close[0] > SMA(20)[0] && Close[1] <= SMA(20)[1]) { }
See the difference?
Using ">" returns true on the crossover (of course) but it also returns true on all bars *after* the crossover where the condition is still true.
Using CrossAbove is more like a finely tuned version of ">" because it only returns true on the *actual* bar (just one bar, not 2, not 3, just 1) where the cross over *actually* occurs, all the remaining bars after the cross over return "false".
CrossAbove returns false for bars after the cross over because of that second check where it looks back 1 bar to see if the values *on that bar* were below.
Using ">" returns "true" repeatedly whereas CrossAbove returns "true" just once.
Make sense?
Comment
-
-
Isn't this thread devoted to the lack of consistent results between 2 strategies that you say are functionally the same?Originally posted by NGorodzhiy View PostThank you, now I understand. What exactly am I "complaining" about?
Therefore, isn't the "complaint" the fact the results are *not* the same?
So, please attach the 2 files that are producing these inconsistent results.
Your "complaint" or "issue" (consider it legal-speak) can be resolved faster if you'd just attach the actual 2 files causing the "issue".
Otherwise, from my perspective, I have insufficient data to help you solve your complaint, er, I mean, problem.
Look, everyone here helping you (except for Ninja folks) is volunteering their time.
Help us to help you (it would go sooooo much faster) if you would just attach the 2 files causing the problem.
Otherwise, if you can't do that (sometimes pro's ask for help here but they can't upload any code because of internal rules at their company), well, I can't read your mind and I can't download/read/investigate code I can't see, so then I'm done being able to help.Last edited by bltdavid; 03-19-2015, 09:45 PM.
Comment
-
The problem is already solved haha. You helped me solve it with your first post, and I appreciate it a lot. Thank you.
Comment
-
Sorry, my mistake.Originally posted by NGorodzhiy View PostSame results, already tested. My friend declared before that the RSI = 2.
I mistook this to say "same incorrect results" ... thus I felt like we needed to see your actual files to investigate further ...
My apologies. Glad to hear it's working!
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
79 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
45 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
29 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
32 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
66 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment