NinjaTrader Support Forum  
X

Attention!

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


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 11-23-2007, 09:52 PM   #1
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default blank indicators on chart?

Greetings,

I'm trying to test an indicator on a chart. I've got the historical bars loaded on the chart but when I apply the indicator to the chart there are no plots in the bottom area where the indicator is to appear below the chart...

I have "Print" statements applied within the indicator in an attempt to determine what the calculations are, however I'm not seeing any output anywhere...how am I to determine how the indicator is operating/calculating??
Burga1 is offline  
Reply With Quote
Old 11-23-2007, 10:14 PM   #2
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi,

I was able to see something in the log, a message that reads:

"...index was out of range. Must be non-negative and less than the size of the collection"...does somebody know the meaning of such as message?
Burga1 is offline  
Reply With Quote
Old 11-23-2007, 10:28 PM   #3
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

I suggest reading our educational resources, e.g. here http://www.ninjatrader-support.com/v...splay.php?f=31

In particular: http://www.ninjatrader-support.com/v...ead.php?t=3170
NinjaTrader_Dierk is offline  
Reply With Quote
Old 11-25-2007, 09:27 PM   #4
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Hello,

I've added the following line to my code, but am still not getting the print statements to give me calculated values:

if(CurrentBar < 6){return;}

I still am seeing the same error in the log...
Burga1 is offline  
Reply With Quote
Old 11-25-2007, 09:31 PM   #5
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

You are going to need to go through your logic and find where it breaks. Comment out complex code segments and leave just the bare necessity. Then, one by one, uncomment segments to see which ones work and which ones don't.

Also, use an arbitrarily large number for your CurrentBar check to see if it is just a mathematically mistake. Try something like
Code:
if (CurrentBar < 100)
     return;
If the code works after that then it means you just had not enough bars loaded.
NinjaTrader_Josh is offline  
Reply With Quote
Old 11-26-2007, 07:18 PM   #6
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Greetings,

OK I tried changing the "min. bars" requirement to 100 and that doesn't seem to be the issue. I have no problem with commenting out lines--however I don't understand why I'm not seeing output to the Output Window. For example the first lines of my strategy (in the "OnBarUpdate" function) are:

if(CurrentBar < 6){return;}

Print(
"The SMI value is: " + SMIndex(2, 13, 3, 25).SMI[0]);
Print(
"The LAST SMI value is: " + SMIndex(2, 13, 3, 25).SMI[1]);
Print(
"The ROC value is: " + SMIndex(2, 13, 3, 25).ROC[0]);
Print(
"The NEW_ROC value is: " + SMIndex(2, 13, 3, 25).NEW_ROC[0]);

Regardless of the values there should be some sort of output someplace--even if the values are "0", correct? I don't know where I'm supposed to accomplish my debugging...
Burga1 is offline  
Reply With Quote
Old 11-26-2007, 10:34 PM   #7
KBJ
Senior Member
 
Join Date: Mar 2007
Location: , Florida, USA
Posts: 663
Thanks: 36
Thanked 7 times in 6 posts
Default

I suggest adding more Print statements....

1. Add a Print statement at the beginning and end of Initialize() just inside the curly braces.
2. Add a Print statement before and after the "if(CurrentBar < 6) {return;}"

And don't put any variables in these print statements.

I do this myself. Sometimes when I've been extraordinarily obtuse, I've inserted a Print statement before/after almost every line of code.

This will find the line that's causing the problem, fast. Then the error will usually "jump out at you", and if not, post the line(s) in question here.

Good luck.
KBJ is offline  
Reply With Quote
Old 11-27-2007, 06:19 PM   #8
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Thank you for your reply. I've added some print statements in places you suggest and removed the variables from within them. I still do not seem to have any print output anyplace I can find (the Output Window and the log)...

I'm attaching 2 screenshots to show part of the indicator code showing where the print statements are, and the second shot shows the indicator running on a chart...if you look at that chart, I'd like to try to determine why the "ROC" and "NEW_ROC" variables are always 100 and 0 respectively. I cannot do this without any output that gives me some idea how the code is calculating these values...
Attached Images
File Type: jpg screen1.JPG (93.2 KB, 13 views)
File Type: jpg screen2.JPG (52.9 KB, 16 views)
Burga1 is offline  
Reply With Quote
Old 11-27-2007, 07:56 PM   #9
Rollins
Senior Member
 
Join Date: Sep 2007
Posts: 201
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi Burga1,

One of my mistakes when I started developing indicators was that I opened the Output Window after adding an indicator and wondering why it is blank.
The window needs to be open before adding the indicator, just mentioning it as a possible source of error.

Cheers
Rollins is offline  
Reply With Quote
Old 11-27-2007, 08:02 PM   #10
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks Rollins, that info is helpful...
Burga1 is offline  
Reply With Quote
Old 11-27-2007, 08:08 PM   #11
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi,

I might be making some progress as I'm getting some messages in the log now...I have a question. I'm getting an error that reads:

"A buy order placed at "date/time" has been ignored since the stop price is less than or equal to the close of the current bar"

My question is, well of course--what's the problem? I'm simply trying to place (buy) orders (when conditions for the strategy exist in the current bar) at 2 pips above the HIGH of the current bar and set a stop at 1 pip below the LOW of the current bar...it would be common for that error message to be true...
Burga1 is offline  
Reply With Quote
Old 11-27-2007, 10:36 PM   #12
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

To send stop loss orders you want to use the SetStopLoss() method.
http://www.ninjatrader-support.com/H...tStopLoss.html
NinjaTrader_Josh is offline  
Reply With Quote
Old 11-28-2007, 06:05 PM   #13
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Thank you Josh. I've made the change as suggested, although I'm not sure why it is needed because the code I had there before was wizard-generated:

EnterLongStopLimit(10000, High[0] + 2 * TickSize, Low[0] + -1 * TickSize, "");

Can somebody also please explain why, after looking at my screenshot, I have this output in the "Output Window" and nothing else...

Begin Init
End Init
Begin Init
End Init

as can be seen in the screenshot I have those print statements in the "Initialize" function but I don't understand why it always outputs the "Output Window" twice like that and nothing else shows up...despite that I have other print statements in the strategy...
Attached Images
File Type: jpg screen1.JPG (93.2 KB, 9 views)
Burga1 is offline  
Reply With Quote
Old 11-29-2007, 01:15 AM   #14
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

EnterLongStopLimit() is not a stop order in the sense of stoploss orders associated with an already open position. Please review this tip for further clarification: http://www.ninjatrader-support.com/v...ead.php?t=3271

The reason it prints twice is because it prints once when you bring up the Strategy Window to start a strategy and again when you actually start the strategy. Your OnBarUpdate() prints will only print out if there are bars to update. Please throw your strategy up onto a chart with a rolling data feed and you will see it print.
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
Chart goes blank when I changed sesion hours nelson Charting 8 02-14-2009 12:11 AM
Drawing on Chart Indicators? ashish Historical NinjaTrader 6.5 Beta Threads 6 11-10-2007 11:59 PM
I just get a blank chart. BlueSky Charting 5 08-04-2007 12:04 AM
Chart indicators not appearing Greg1 Charting 3 04-14-2007 01:46 PM
Some indicators not showing on eSignal chart SuzyG Charting 1 01-26-2007 02:55 AM


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