NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 06-11-2012, 11:50 AM   #1
pstrusi
Senior Member
 
Join Date: Nov 2011
Posts: 238
Thanks: 94
Thanked 14 times in 12 posts
Default A very weird situation with Median[2]

Ninjas, this should be very easy to solve for you, this situation is this

If I add this condition below, it works perfectly:

if (Close[0]-Median[1]> 0)
{
EnterLong();
}

But if I add this one, I have non result, zero event, why?

if (Close[0]-Median[2]> 0)
{
EnterLong();
}
pstrusi is offline  
Reply With Quote
Old 06-11-2012, 11:56 AM   #2
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

pstrusi,

Could you possible post your code here?

It could be you are trying to access Median[2] when it doesn't exist yet.

if ( CurrentBar < 2) return;

added to the beginning of your OnBarUpdate() may help.
NinjaTrader_AdamP is offline  
Reply With Quote
The following user says thank you to NinjaTrader_AdamP for this post:
Old 06-11-2012, 11:59 AM   #3
pstrusi
Senior Member
 
Join Date: Nov 2011
Posts: 238
Thanks: 94
Thanked 14 times in 12 posts
Default

I'ts no necessary, a very fool error from me...as you well said Median[2] didn't exist cause in Barsrequired I had set 1.

Thanks my friend
pstrusi 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
NT on tablets; what is the situation? Martinigue Miscellaneous Support 1 04-30-2012 02:25 AM
Rare situation "CJS" General Programming 4 02-13-2012 09:19 AM
strange situation with strategy names daglas Strategy Development 3 10-03-2011 10:37 AM
Median indicator ? SARdynamite Indicator Development 10 11-05-2010 09:06 AM
Calculating the median of 4 values poseidon_sthlm General Programming 3 11-12-2009 06:50 AM


All times are GMT -6. The time now is 07:33 AM.