![]() |
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
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Apr 2009
Location: Elche, Spain
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Apr 2009
Location: Elche, Spain
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
|
The plot obtained is different. Why? View image.
|
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Apr 2009
Location: Elche, Spain
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
You would need to keep track of each state during the loop and only at the end can you set the plot.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |