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 > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 10-06-2009, 09:45 AM   #1
pequemec
Junior Member
 
Join Date: Apr 2009
Location: Elche, Spain
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
Default Why not get the same result?

Hi in my first post
My code is:

if (Close[0] > Close[1]
&& Close[1] > Close[2]
&& Close[2] > Close[3])
Tradicional.Set(1);
else
Tradicional.Set(-1);


Compared with:

if (CurrentBar < Period)
return;

for (int i = 0; i < Period; i++)
{
if (Close[i] > Close[i+1])
Iterativos.Set(1);
else
Iterativos.Set(-1);
}


I do not get the same results.

TIA. Best regards.
pequemec is offline  
Reply With Quote
Old 10-06-2009, 09:51 AM   #2
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

pequemec,

If you could describe what you see differently between the two then we could be able to help you understand why it would be different. Thank you.
NinjaTrader_Josh is offline  
Reply With Quote
Old 10-06-2009, 02:22 PM   #3
pequemec
Junior Member
 
Join Date: Apr 2009
Location: Elche, Spain
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
Default

The plot obtained is different. Why? View image.
Attached Images
File Type: png result1.png (39.3 KB, 8 views)
File Type: png result2.png (48.7 KB, 9 views)
pequemec is offline  
Reply With Quote
Old 10-06-2009, 02:37 PM   #4
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

The logic in the two are fundamentally different.

In the first case, you require all 4 closes to be the greater than the previous close at the exact same time.

In the second case, what you ultimately set your plot to only depends on the last run through of your for loop. You just override old settings with each new loop through instead of assuring that all 4 closes are > than previous simultaneously.
NinjaTrader_Josh is offline  
Reply With Quote
Old 10-06-2009, 04:56 PM   #5
pequemec
Junior Member
 
Join Date: Apr 2009
Location: Elche, Spain
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
Default

Correct, but the question is:

Can represent case 1 with a similar logic to the case 2?
What would be the logic using looping commands?

Thank you.
pequemec is offline  
Reply With Quote
Old 10-07-2009, 07:08 AM   #6
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

You would need to keep track of each state during the loop and only at the end can you set the plot.
NinjaTrader_Josh 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
Reloading Workspace Can Result in Inaccessible NT Windows Jim W. Suggestions And Feedback 6 11-29-2010 06:11 AM
Same strategy on 2 pc, different result ninjaq Strategy Development 5 03-25-2009 10:53 AM
Result of last trade chuckt101 Strategy Development 1 02-10-2009 12:05 AM
Write my Backtest Result on the Output window adelvalle General Programming 2 12-04-2008 11:01 PM
Result of previous trade in backtest JonesWooHoo Automated Trading 4 10-21-2007 03:15 AM


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