Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get current price Info from addon

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Hello Powerbucker,

    You might be able to achieve this with unsupported tools like static class.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #17
      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


        #18
        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


          #19
          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


            #20
            Hello Powerbucker,

            You will need to use the dispatcher of each window not the application.

            Have a look at the ListChartsIndicatorsExample I've provided you in post # 4 on lines 246 to 258.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #21
              Originally posted by NinjaTrader_ChelseaB View Post
              Hello 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
              Hi,

              I'm trying to get the Yesterday low from an indicator like this

              Code:
                      public void test()
                      {
                          double value = PriorDayOHLC().PriorLow[0];
                          Print("The prior session low value is " + value.ToString());
                      }
              ​
              Buy I'm always getting 0.

              Why?

              Thks

              Comment


                #22
                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
                563 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                329 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                547 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                548 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X