NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


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

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 03-27-2007, 08:04 AM   #1
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 426
Thanks: 0
Thanked 2 times in 2 posts
Send a message via AIM to funk101
Post imported post

This must be simple, but can't find, a method for return the name of the chart that a strategy is being run on?
funk101 is offline  
Reply With Quote
Old 03-27-2007, 08:13 AM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

Charts do not have names. Do you mean the instrument?

Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 03-27-2007, 08:38 AM   #3
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 426
Thanks: 0
Thanked 2 times in 2 posts
Send a message via AIM to funk101
Post imported post

Yes, sorry. Any way to identify the chart/instrument when outputting to output window
funk101 is offline  
Reply With Quote
Old 03-27-2007, 08:46 AM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

Please see this post - http://ninjatrader.mywowbb.com/forum20/1554.html

It will provide you with the answer you seek.

Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 03-27-2007, 08:50 AM   #5
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 426
Thanks: 0
Thanked 2 times in 2 posts
Send a message via AIM to funk101
Post imported post

Yes, that's it. So, where do *I* find these types of things out? It's not in the online help. I hate to keep asking these lame questions.
funk101 is offline  
Reply With Quote
Old 03-27-2007, 08:58 AM   #6
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

This was not documented yet. It is in my current working DOC that will be published with the next update. The complete DOC will be done by production release around the second week of April.

Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 03-27-2007, 09:03 AM   #7
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 426
Thanks: 0
Thanked 2 times in 2 posts
Send a message via AIM to funk101
Post imported post

Cool, thanks...I don't feel like a "lame-o" now
funk101 is offline  
Reply With Quote
Old 03-27-2007, 10:32 AM   #8
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 426
Thanks: 0
Thanked 2 times in 2 posts
Send a message via AIM to funk101
Post imported post

Can you explain why this code doesn't execute?



This is set -> Initialize();

instrumentName = Instrument.FullName;

----

This is run -> OnBarUpdate();

if
(Position.MarketPosition != MarketPosition.Flat){

Print (instrumentName+
" PnL "+Position.GetProfitLoss(Close[0], PerformanceUnit.Points));

if (Position.GetProfitLoss(Close[0],PerformanceUnit.Points) >= 9){

Print (instrumentName+
" trail stop set to 6");

SetTrailStop(CalculationMode.Ticks,
6);

}

}
funk101 is offline  
Reply With Quote
Old 03-27-2007, 10:36 AM   #9
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

Check the log tab, I suspect you get a null reference exception in which case NT stops processing the strategy. Instrument may not yet be set in Initialize().

Alternatively, you can just access in OnBarUpdate()

Instrument.FullName

or

if (instrumentName.Length == 0)
instrumentName = Instrument.FullName;


Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 03-27-2007, 10:51 AM   #10
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 426
Thanks: 0
Thanked 2 times in 2 posts
Send a message via AIM to funk101
Post imported post

No, intrumentName is set, I can see in output window. The strategy runs.

Just trying to reset TrailStop if profit is >= 9 PerformanceUnit.Points...hmm
funk101 is offline  
Reply With Quote
Old 03-28-2007, 05:25 PM   #11
ThePatientOne
Member
 
Join Date: Feb 2007
Location: , ,
Posts: 71
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

I am attempting to use Instrument.FullName inside of the OnBarUpdate method of a custom indicator but am receiving a compile time error stating:'

An object reference is required for the nonstatic field, method, or property ...

I was assuming that this object was part of the core NinjaTrader dll. Is this so? Is there something I am missing regarding syntax? My exact code line is:

symbolName = Instrument.FullName;


ThePatientOne is offline  
Reply With Quote
Old 03-28-2007, 05:36 PM   #12
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 426
Thanks: 0
Thanked 2 times in 2 posts
Send a message via AIM to funk101
Post imported post

I'm assuming you need to initialize in "#region Variables"

private
string symbolName = "";




funk101 is offline  
Reply With Quote
Old 03-28-2007, 06:04 PM   #13
ThePatientOne
Member
 
Join Date: Feb 2007
Location: , ,
Posts: 71
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Already thought of that one. I only need the variable in the OnBarUpdate so I initially declared it as local to that method. Then, after getting the error, I put it in the classes global variable declaration and initialized it to no success.

Thanks for the response though.
ThePatientOne is offline  
Reply With Quote
Old 03-29-2007, 01:01 AM   #14
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

Please use

symbolName = Bars.Instrument.FullName;

for now.

Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 03-29-2007, 01:16 AM   #15
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

The current documentation is not reflective of actual usage. The next release will allow you to accesss "Instrument" within an indicator without having to go through the "Bars" object.

Ray
NinjaTrader_Ray 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


All times are GMT -6. The time now is 05:04 PM.