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 02-15-2009, 07:08 AM   #1
Obi
Member
 
Join Date: Mar 2007
Location: , ,
Posts: 55
Thanks: 0
Thanked 0 times in 0 posts
Red face NinjaScript Buggy and Inacurate. Please Help !!!

Hello,

I created a test indicator (accepting the default values of the wizard just to have a bare minimum indicator, in order to debug the odd behavior)

The resulting created indicator code and the test code:

protected override void OnBarUpdate()
{
Print("");

for (int idx =0; idx < 20; idx++)
{
Print("Value before : " + Close[idx]);
}
Print("");

// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Plot0.Set(Close[0]);
}

After loading this to a "3Minutes YM Chart, Connected to simulator", I get the following odd result:

Value before : 10594


1. The print shows only one value (the above value)
2. This value is not even the last value showing on the chart ( 10729 is the last value).
3. 10 minutes, 30 minutes and An hour later, I still get the same single value.

I changed the code to the following:

protected override void OnBarUpdate()
{
Print("Value After : " + Close[0]);
Print("Value After 2: " + Close[1]);
Print("Value After 3: " + Close[2]);
Print("");

for (int idx =0; idx < 20; idx++)
{
Print("Value before : " + Close[idx]);
}
Print("");

// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Plot0.Set(Close[0]);
}

The result (some 10 minutes later):

Value After : 10594


That's it!??? No need to tell you that this is very odd and extremely frustrating.

I desperately need your help and solution to this bug as all my work is currently suspended until this is resolved.

Obi
Obi is offline  
Reply With Quote
Old 02-15-2009, 07:32 AM   #2
mrlogik
Certified NinjaScript Consultant
 
mrlogik's Avatar
 
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
Default

First, you need to convert the Close[] to a string before you print it out
Code:
Close[0].ToString();
Second, you should have the following statement before your for loop.
Code:
if(CurrentBar < 20)
    return;
The reason for this is you don't want to cause an exception by trying to access data that doesn't yet exist on the chart.

hope this helps
"You look closely enough, you can find everything has a ... weak spot where it can break, sooner or later"

PureLogikTrading
mrlogik is offline  
Reply With Quote
Old 02-15-2009, 08:10 AM   #3
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

Hi Obi, I already responded to your email sent to our support inbox.

Thanks for your input mrlogik.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 02-15-2009, 11:25 AM   #4
Obi
Member
 
Join Date: Mar 2007
Location: , ,
Posts: 55
Thanks: 0
Thanked 0 times in 0 posts
Unhappy

Hi NinjaTrader_Bertrand and Mr.Logik,

The following still give the same result as explained earlier:

protected override void OnBarUpdate()
{
Print("Value After : " + Close[0].ToString());
Print("Value After 2: " + Close[1].ToString());
Print("Value After 3: " + Close[2].ToString());
Print("");

// for (int idx =0; idx < 20; idx++)
// {
// Print("Value before : " + Close[idx]);
// }
// Print("");

// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Plot0.Set(Close[0]);
}

Result:

Value After : 10594

As you can see, hours after I reported the issue, I'm still getting the same single value.

Can you please have a look at this. It's blocking everything.

Obi
Obi is offline  
Reply With Quote
Old 02-15-2009, 12:07 PM   #5
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Default

I did not see that you added this to your code:

if(CurrentBar < 20)
return;
NinjaTrader_Ray is offline  
Reply With Quote
Old 02-15-2009, 08:52 PM   #6
mrlogik
Certified NinjaScript Consultant
 
mrlogik's Avatar
 
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
Default

Check the LOG tab as well for errors
"You look closely enough, you can find everything has a ... weak spot where it can break, sooner or later"

PureLogikTrading
mrlogik 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
NinjaScript Buggy and Inacurate. Please Help !!! Obi Miscellaneous Support 1 02-15-2009 08:59 AM
Need Help with NinjaScript duckfan312 Strategy Development 1 10-31-2008 08:06 AM
Workspaces buggy... funk101 Historical NinjaTrader 6.5 Beta Threads 1 11-24-2007 01:49 PM
Control center interface buggy... funk101 Miscellaneous Support 5 10-21-2007 04:14 AM
BUG: Manually entering executions is buggy in NT6 Joel Reymont Suggestions And Feedback 9 01-06-2007 08:19 AM


All times are GMT -6. The time now is 06:18 PM.