![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Senior Member
Join Date: Feb 2006
Location: London U.K.
Posts: 152
Thanks: 3
Thanked 2 times in 2 posts
|
Can anyone tell me why this does not work? It never prints an arrow.
protected override void OnBarUpdate() { if (Low[0] < Low[1]) // Problem is in this line. { DrawArrowUp("Up" + CurrentBar, false, 0, Low[0] - (1 * TickSize), Color.Blue); } } I know the problem is in the 'if' statement, if I change it to if (Close[0] >= Median[0]) It prints arrows correctly. Thanks Dave |
|
|
|
|
|
#2 |
|
Member
Join Date: Aug 2009
Posts: 38
Thanks: 0
Thanked 0 times in 0 posts
|
Dave,
I was about to post a near identical question to the board when I saw your post from today. I'm having the same problem with simple logic. My code is as follows: double myInteger = Close[1]; if (Close[0] > myInteger) { Plot0.Set(100); } else { Plot0.Set(0); } My code is actually a modified thing that I did during troubleshooting but you'll see that the problem boils down to the same thing... Comparing basic OHLC data between two bars when one references a historic value. Close[0] > Close[1] Just like you... if I do something like Close[0] = Open[0], it works. But once I reference a [1] or [2], it breaks. This seems so fundamental that I feel like an idiot for not figuring it out. But I'm glad to know that I'm not alone and there's clearly some trick we're both missing. |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Feb 2006
Location: London U.K.
Posts: 152
Thanks: 3
Thanked 2 times in 2 posts
|
I went through the same agony. It seemed so simple that I thought I must be doing something stupid.
Hopefuly someone will have the answer. |
|
|
|
|
|
#4 |
|
Member
Join Date: Aug 2009
Posts: 38
Thanks: 0
Thanked 0 times in 0 posts
|
In case any NinjaTrader admin reads this thread and wants to chime in... here's the simplest demonstration of the problem I could think of:
If you follow Lesson 1 from the NinjaScript help tutorials you create an indicator that draws a line every time the close price = the open price. The code is this: protected override void OnBarUpdate() { Plot0.Set(Open[0] == Close[0] ? 1 : 0); } If all you do is change it to this: protected override void OnBarUpdate() { Plot0.Set(Open[0] == Close[1] ? 1 : 0); } The whole thing fails to plot. No errors come up. And it compiles successfully... just is a blank plot on the chart. |
|
|
|
|
|
#5 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Errors do come up with those codes you guys are using. You will see it in the Control Center log. Please see this tip on what needs to be done: http://www.ninjatrader-support2.com/...ead.php?t=3170
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Feb 2006
Location: London U.K.
Posts: 152
Thanks: 3
Thanked 2 times in 2 posts
|
So there you go Noevictorian, we WERE doing something wrong.
Thanks very much Josh, that fixed it. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Logic Error | texasnomad | Strategy Development | 2 | 07-23-2009 05:07 AM |
| Help with Exception Logic | shawnj | General Programming | 6 | 12-08-2008 06:21 AM |
| simple order management logic problem | Willl | Strategy Development | 3 | 03-27-2008 11:13 AM |
| Order Pending Logic | Oli | Automated Trading | 12 | 04-02-2007 03:13 AM |
| Order logic and OnBarUpdate | MrBaffalo | Strategy Development | 2 | 01-29-2007 04:54 AM |