You might be able to achieve this with unsupported tools like static class.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Get current price Info from addon
Collapse
X
-
Great !! Thanks
I'm now adding a new menu option, to check open chart windows.
But, on menu event click, with this code
foreach (Window window in Globals.AllWindows)
{
blablabla
}
I get -> "The calling thread cannot access this object because a different thread owns it." error.
Any idea?
Comment
-
Hello Powerbucker,
This is Gaby following up for Chelsea who is out of office.
Use ChartControl.Dispatcher.InvokeAsync when accessing the button because the NinjaScript object runs on a non-UI thread.
Example script demonstrating this concept:
https://forum.ninjatrader.com/forum/...39#post1180339
Comment
-
I can't get it
My code
if (menuItem.Name == "mnuAddonIsra")
{
NinjaTrader.Code.Output.Process("mnuAddonIsra", PrintTo.OutputTab1);
Application.Current.Dispatcher.InvokeAsync(() =>
{
var allWindows = NinjaTrader.Core.Globals.AllWindows.Count;
NinjaTrader.Code.Output.Process(allWindows.ToStrin g(), PrintTo.OutputTab1);
foreach (Window window in NinjaTrader.Core.Globals.AllWindows)
{
NinjaTrader.Code.Output.Process("Window Title: " + window.Title, PrintTo.OutputTab1);
}
});
}
I only see in output window "Window title: " once. Not the title. And only passes once when there are 7 windows open (System shows allWindows = 7)
Comment
-
Hi,Originally posted by NinjaTrader_ChelseaB View PostHello Powerbucker,
Welcome to the NinjaTrader forums!
Please note, any script that disables or modifies the intended functionality of NinjaTrader is not supported.
I would recommend instead adding a separate panel with your own custom buttons.
The SampleWPFModifications reference sample in the help guide provides a demonstration of both adding a panel and locating ChartTrader buttons.
If the script is an indicator, getting the current market price and previous day's high and low is straight forward.
The current market price would be the Close[0] (or GetCurrentAsk() / GetCurrentBi()), while the previous day high and low can be retrieved by calling PreviousDayOHLC().PriorHigh[0] / PriorDayOHLC().PriorLow[0].
From an addon window you would need to do a BarsRequest to request data.
Below is a link to an example.
https://ninjatrader.com/support/foru...208#post786208
I'm trying to get the Yesterday low from an indicator like this
Buy I'm always getting 0.Code:public void test() { double value = PriorDayOHLC().PriorLow[0]; Print("The prior session low value is " + value.ToString()); }
Why?
Thks
Comment
-
Hello Powerbucker,
Addons cannot use Series<T> objects (and thus cannot call an indicator).
Only indicators and strategies applied to a chart can use series.
If you are using an indicator and calling a method from OnBarUpdate(), this will have native Price series which can be used from that method (and call an indicator using the native price series as the input series).
From an addon, you can access the indicator instance that is applied to a chart (with unsupported code) and access the series native to the indicator.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
557 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
324 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
545 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment