NinjaTrader Support Forum  

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

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 06-19-2012, 02:52 AM   #16
suprsnipes
Senior Member
 
Join Date: Aug 2008
Posts: 238
Thanks: 20
Thanked 5 times in 5 posts
Default

Ok, the print output is showing the correct information most of the time, what I would like to do is not include the inside ask so only positions 1 through to 4 if you could help me out with the syntax that would be great.

maxValue=0;
maxAskSizeLevel=0;
for(int i=0; i<5; i++)
{
if (e.MarketDepth.Ask[i].Volume > maxValue)
{
maxValue = e.MarketDepth.Ask[i].Volume;
maxAskSizeLevel = i;
suprsnipes is offline  
Reply With Quote
Old 06-19-2012, 02:55 AM   #17
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

...then you would need to do your loop from 1 to <5, so starting at the first level instead of level 0.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 08-07-2012, 06:47 PM   #18
suprsnipes
Senior Member
 
Join Date: Aug 2008
Posts: 238
Thanks: 20
Thanked 5 times in 5 posts
Default

I would be grateful if I could get some assistance as to why the Print() function for the code below is sending out "extra" prints 1 correct at the time and 2 not correct. Here I will give example. The code is in addition to the market depth sample.

Code:
            maxValue=0;
            maxAskSizeLevel=-1;
            for(int i=1; i<5; i++)
            {
            if (e.MarketDepth.Ask[i].Volume > maxValue)
            {    
            maxValue = e.MarketDepth.Ask[i].Volume;
            maxAskSizeLevel = i;
            Print("MAX Ask |" + maxValue + " | " + maxAskSizeLevel);
            }
            }
MAX Ask |89 | 3 Time 10:42:44 - Correct Output
MAX Ask |41 | 1 Time 10:42:44 - ?
MAX Ask |50 | 2 Time 10:42:44 - ?
MAX Ask |89 | 3 Time 10:42:44 - Correct Output
MAX Ask |41 | 1 Time 10:42:44 - ?
MAX Ask |50 | 2 Time 10:42:44 - ?
MAX Ask |89 | 3 Time 10:42:44 - Correct Output
MAX Ask |41 | 1 Time 10:42:44 - ?
MAX Ask |50 | 2 Time 10:42:44 - ?
MAX Ask |89 | 3 Time 10:42:44 - Correct Output
MAX Ask |41 | 1 Time 10:42:44 - ?
MAX Ask |50 | 2 Time 10:42:44 - ?
MAX Ask |89 | 3 Time 10:42:44 - Correct Output

Regards,
suprsnipes
suprsnipes is offline  
Reply With Quote
Old 08-07-2012, 08:13 PM   #19
sledge
Senior Member
 
Join Date: Aug 2010
Location: Washington, D.C.
Posts: 1,267
Thanks: 192
Thanked 332 times in 287 posts
Default

It is coded exactly as you have put.

Each one is increasing

Try moving your print OUTSIDE of the IF statement

Quote:
Originally Posted by suprsnipes View Post
I would be grateful if I could get some assistance as to why the Print() function for the code below is sending out "extra" prints 1 correct at the time and 2 not correct. Here I will give example. The code is in addition to the market depth sample.

Code:
            maxValue=0;
            maxAskSizeLevel=-1;
            for(int i=1; i<5; i++)
            {
            if (e.MarketDepth.Ask[i].Volume > maxValue)
            {    
            maxValue = e.MarketDepth.Ask[i].Volume;
            maxAskSizeLevel = i;
            Print("MAX Ask |" + maxValue + " | " + maxAskSizeLevel);
            }
            }
MAX Ask |89 | 3 Time 10:42:44 - Correct Output
MAX Ask |41 | 1 Time 10:42:44 - ?
MAX Ask |50 | 2 Time 10:42:44 - ?
MAX Ask |89 | 3 Time 10:42:44 - Correct Output
MAX Ask |41 | 1 Time 10:42:44 - ?
MAX Ask |50 | 2 Time 10:42:44 - ?
MAX Ask |89 | 3 Time 10:42:44 - Correct Output
MAX Ask |41 | 1 Time 10:42:44 - ?
MAX Ask |50 | 2 Time 10:42:44 - ?
MAX Ask |89 | 3 Time 10:42:44 - Correct Output
MAX Ask |41 | 1 Time 10:42:44 - ?
MAX Ask |50 | 2 Time 10:42:44 - ?
MAX Ask |89 | 3 Time 10:42:44 - Correct Output

Regards,
suprsnipes
sledge is offline  
Reply With Quote
The following user says thank you to sledge for this post:
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
Recalculating position size based on account size, % risked and stop loss clivehunt Strategy Development 18 03-22-2009 11:25 AM
OnMarketDepth callback CraigC General Programming 17 06-30-2008 11:34 PM
Bug in OnMarketDepth maxima Indicator Development 2 05-05-2008 02:44 PM
OnMarketDepth details ct General Programming 5 11-30-2007 06:01 AM
Play beep OnMarketDepth MrBaffalo Indicator Development 4 11-19-2007 10:39 PM


All times are GMT -6. The time now is 07:32 PM.