![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: May 2008
Posts: 221
Thanks: 12
Thanked 2 times in 2 posts
|
I'm using your SampleMarketDepth script and just added a couple of simple lines, but get an error I can not explain. All I did was add this at the end;
double AskPrice0 = e.MarketDepth.Ask[0].Volume; double AskPrice1 = e.MarketDepth.Ask[1].Volume; double AskPrice2 = e.MarketDepth.Ask[2].Volume; double AskPrice3 = e.MarketDepth.Ask[3].Volume; double AskPrice4 = e.MarketDepth.Ask[4].Volume; data = AskPrice0 + AskPrice1 + AskPrice2 + AskPrice3 + AskPrice4; Plot0.Set(data); I ran this on the Simulator and it ran fine for about 1 1/2 hours, then I get this error message, "Error on calling "OnMarketDepth" 'MyFileName': You are accessing an index with a value that is invalid since its out of range, I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars in the chart." I usually see this error if I forget to put this in the beginning of my script, " if(CurrentBar < xx)return;" But when this is the problem, the script will not work at all until I insert the CurrentBar line. My code executes fine, then stops suddenly. If I open up the Indicator window of the chart and click OK, then it starts working again, but at some point later, errors again. So it appears there is a problem processing the data a some point. I added a Print statement to see if anything unusual showed up, but when the error occurs, it just prints the error and the data before that looked normal. Any suggestions as to how I can stop this error from occuring? Thanks, Safetrading |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Sep 2008
Posts: 543
Thanks: 80
Thanked 187 times in 131 posts
|
You're asking to plot 5 levels of depth, and you're probably getting that error at a time when there aren't 5 levels of depth to plot.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SampleMarketDepth example | MXASJ | Version 7 Beta General Questions & Bug Reports | 5 | 03-30-2010 08:34 AM |
| SampleMarketDepth | MXASJ | Version 7 Beta General Questions & Bug Reports | 1 | 02-24-2010 10:19 AM |
| SampleMarketDepth is back | Kowal | General Programming | 5 | 07-29-2009 10:57 AM |