Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Accessing chart name via NT scipt
Collapse
X
-
imported post
Please see this post - http://ninjatrader.mywowbb.com/forum20/1554.html
It will provide you with the answer you seek.
Ray
RayNinjaTrader Customer Service
Comment
-
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);
}
}
Comment
-
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
RayNinjaTrader Customer Service
Comment
-
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;
Comment
-
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.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by SalmaTrader, 07-07-2026, 10:26 PM
|
0 responses
47 views
0 likes
|
Last Post
by SalmaTrader
07-07-2026, 10:26 PM
|
||
|
Started by CarlTrading, 07-05-2026, 01:16 PM
|
0 responses
22 views
0 likes
|
Last Post
by CarlTrading
07-05-2026, 01:16 PM
|
||
|
Started by CaptainJack, 06-17-2026, 10:32 AM
|
0 responses
15 views
0 likes
|
Last Post
by CaptainJack
06-17-2026, 10:32 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:15 AM
|
0 responses
21 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:15 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:06 AM
|
0 responses
23 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:06 AM
|

Comment