![]() |
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
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
|
This must be simple, but can't find, a method for return the name of the chart that a strategy is being run on?
|
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Charts do not have names. Do you mean the instrument?
Ray
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
|
Yes, sorry. Any way to identify the chart/instrument when outputting to output window
|
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Please see this post - http://ninjatrader.mywowbb.com/forum20/1554.html
It will provide you with the answer you seek. Ray
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
|
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.
|
|
|
|
|
|
#6 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
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
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
|
Cool, thanks...I don't feel like a "lame-o" now
|
|
|
|
|
|
#8 |
|
Senior Member
|
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); } } |
|
|
|
|
|
#9 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
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
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#10 |
|
Senior Member
|
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 |
|
|
|
|
|
#11 |
|
Member
Join Date: Feb 2007
Location: , ,
Posts: 71
Thanks: 0
Thanked 0 times in 0 posts
|
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; |
|
|
|
|
|
#12 |
|
Senior Member
|
I'm assuming you need to initialize in "#region Variables"
privatestring symbolName = ""; |
|
|
|
|
|
#13 |
|
Member
Join Date: Feb 2007
Location: , ,
Posts: 71
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#14 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Please use
symbolName = Bars.Instrument.FullName; for now. Ray
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#15 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
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
Ray
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|