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 08-18-2012, 10:30 AM   #1
dukeb
Senior Member
 
Join Date: Mar 2012
Posts: 102
Thanks: 29
Thanked 4 times in 4 posts
Default Determine Instrument name

The following code;
protectedoverridevoid Initialize()
{
BPer= BarsPeriod.Value;


Add(PeriodType.Minute,
90);

CalculateOnBarClose =
true;
InstrumentName=(Instrument.MasterInstrument.Name[
1].ToString());
BValue= (BarsPeriods[
1].Id.ToString()) ;
Print (BValue);
Print (BPer);
Print (InstrumentName);
}
Yields the following results on a GBPUSD 30 minute chart;
Minute
30
B
Minute
30
Q

The 'Minute' and '30' are correct.
Why are 'B' and 'Q' being returned? I am expecting 'GBPUSD'
If I use InstrumentName=(Instrument.FullName[0].ToString()); I get the same type of results for InstrumentName.
I checked the ref mat'l that I found referenced on the forum. I believe I did what was indicated on the forum.
Thank you,
Duke


dukeb is offline  
Reply With Quote
Old 08-18-2012, 10:54 AM   #2
sledge
Senior Member
 
Join Date: Aug 2010
Location: Washington, D.C.
Posts: 1,179
Thanks: 178
Thanked 299 times in 257 posts
Default

Instrument.FullName[1].ToString() ?


Quote:
Originally Posted by dukeb View Post
The following code;
protectedoverridevoid Initialize()
{
BPer= BarsPeriod.Value;


Add(PeriodType.Minute,
90);

CalculateOnBarClose =
true;
InstrumentName=(Instrument.MasterInstrument.Name[
1].ToString());
BValue= (BarsPeriods[
1].Id.ToString()) ;
Print (BValue);
Print (BPer);
Print (InstrumentName);
}
Yields the following results on a GBPUSD 30 minute chart;
Minute
30
B
Minute
30
Q

The 'Minute' and '30' are correct.
Why are 'B' and 'Q' being returned? I am expecting 'GBPUSD'
If I use InstrumentName=(Instrument.FullName[0].ToString()); I get the same type of results for InstrumentName.
I checked the ref mat'l that I found referenced on the forum. I believe I did what was indicated on the forum.
Thank you,
Duke


sledge is offline  
Reply With Quote
Old 08-18-2012, 01:03 PM   #3
dukeb
Senior Member
 
Join Date: Mar 2012
Posts: 102
Thanks: 29
Thanked 4 times in 4 posts
Default

Upon more research ---
When I omit the secondary chart ( // Add(PeriodType.Minute,90)
And use --- InstrumentName=(Instrument.FullName.ToString());
Print (InstrumentName);

I get--
$GBPUSD ---good
NQ 03-12 ---???

Why are two instruments returned?
dukeb is offline  
Reply With Quote
Old 08-19-2012, 01:42 PM   #4
sledge
Senior Member
 
Join Date: Aug 2010
Location: Washington, D.C.
Posts: 1,179
Thanks: 178
Thanked 299 times in 257 posts
Default

Quote:
Originally Posted by dukeb View Post
Upon more research ---
When I omit the secondary chart ( // Add(PeriodType.Minute,90)
And use --- InstrumentName=(Instrument.FullName.ToString());
Print (InstrumentName);

I get--
$GBPUSD ---good
NQ 03-12 ---???

Why are two instruments returned?
I see what is going on. You are just printing 1 character out of the string.

Code:
Print ("InstrumentName3="+Instrument.FullName[0].ToString()+
                          Instrument.FullName[1].ToString()+
                          Instrument.FullName[2].ToString()+
                          Instrument.FullName[3].ToString()+
                          Instrument.FullName[4].ToString()+
                          Instrument.FullName[5].ToString()
                          );
Print ("InstrumentName4="+Instrument.FullName.ToString() );
HTML Code:
Output:
InstrumentName3=ES 09-
InstrumentName4=ES 09-12
sledge is offline  
Reply With Quote
Old 08-19-2012, 01:44 PM   #5
sledge
Senior Member
 
Join Date: Aug 2010
Location: Washington, D.C.
Posts: 1,179
Thanks: 178
Thanked 299 times in 257 posts
Default

Quote:
Originally Posted by dukeb View Post
Upon more research ---
When I omit the secondary chart ( // Add(PeriodType.Minute,90)
And use --- InstrumentName=(Instrument.FullName.ToString());
Print (InstrumentName);

I get--
$GBPUSD ---good
NQ 03-12 ---???

Why are two instruments returned?

How many data series are in your chart?

Right click the chart, Data Series , and on lower left corner.

You might have $GBPUSD and then NQ 03-12.


If NQ 03-12 is there, try to remove it. If you can't, Create a new chart for $GBPUSD.

good luck
sledge is offline  
Reply With Quote
Old 08-19-2012, 05:06 PM   #6
dukeb
Senior Member
 
Join Date: Mar 2012
Posts: 102
Thanks: 29
Thanked 4 times in 4 posts
Default

This behavior is peculiar to the strategy tester. Before I go to the strategy tester, I open the output box and discover the reference to NQ. I then delete this from the output box, run the tester. Everything is fine. I had assumed that it was being placed in the output box as a result of the actual testing. Not so. It appears to be a wierd type of behavior that has nothing to do with the testing and is placed there before the testing.
dukeb is offline  
Reply With Quote
Old 08-20-2012, 07:24 AM   #7
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

dukeb,

Do you perhaps have a toy example strategy I can use to verify this? I would also need to have replication steps.
NinjaTrader_AdamP 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
How to determine if SMA is moving up or down krakken Automated Trading 4 08-09-2011 06:59 PM
How to determine if Optimizer stuck? sajosh Strategy Analyzer 9 07-21-2011 02:59 PM
Determine if using 64bit bobcat70 Miscellaneous Support 1 09-14-2010 11:33 PM
How to determine whether an instrument is dealable or not Buthus Strategy Development 7 11-06-2009 06:30 AM
Easy way to determine last bar? terenyi General Programming 2 09-08-2008 03:44 PM


All times are GMT -6. The time now is 02:52 PM.