![]() |
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
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
|
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?? |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#3 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
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
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
|
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... |
|
|
|
|
|
#5 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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;
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
|
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... |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Mar 2007
Location: , Florida, USA
Posts: 663
Thanks: 36
Thanked 7 times in 6 posts
|
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. |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
|
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... |
|
|
|
|
|
#9 |
|
Senior Member
Join Date: Sep 2007
Posts: 201
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#10 |
|
Senior Member
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks Rollins, that info is helpful...
|
|
|
|
|
|
#11 |
|
Senior Member
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
|
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... |
|
|
|
|
|
#12 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
To send stop loss orders you want to use the SetStopLoss() method.
http://www.ninjatrader-support.com/H...tStopLoss.html
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#13 |
|
Senior Member
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
|
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... |
|
|
|
|
|
#14 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |