Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting Panel Number via Mouse Click Points

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

    Getting Panel Number via Mouse Click Points

    Hello,

    How would one get which panel the mouse clicked on via click points? The code converts the X and Y values to time and price. I want to get the panel number as well.

    Thanks
    Unsuitable
    NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

    #2
    Hi Unsuitable, thanks for posting. This indicator gets time and price of the panel it is running in. The render window for indicators is clipped to the panel itself, so it can only work in one panel, you would need to run the indicator in each panel of the chart to make it work with multiple different price axis.



    Kind regards.

    Comment


      #3
      Hello ChrisL,

      Indeed that is the code I'm referring to. Damn I thought there would be a way to detect which panel it clicked on. I guess not.

      Oh wait, if we take the event source (e.source.ToString()) it spits out the following:

      Code:
      Panel: Index=1 #[B=0;I=1;S=0;D=0] min=12477.9770185713 max=12884.7072933442
      So we can get the panel info. From here parse out the index number and good to go.
      Unsuitable
      NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

      Comment


        #4
        Tried to set the text.PanelIndex and that does nothing. This property is probably inherited by indicators in which the panel property can be set by the user.

        Perhaps change the attachedTo property. However, nobody seems to know how it works. Also, draw objects within a separate panel from the price panel appear to have no knowledge of indicators within the price panel.

        At the moment, the code has which panel the mouse clicked on. It's a matter of setting the draw object to the correct panel. Draw objects do not seem to operate on panels, but rather on what's it attached to.
        Unsuitable
        NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

        Comment


          #5
          Hi Unsuitable, you would need to test it out, but you can get a list of all the panels from ChartControl, and the Panel has a ChartScale object where you can extract price and time data from the XY coordinates:

          https://ninjatrader.com/support/help...properties.htm Chart Control has ChartPanels>
          https://ninjatrader.com/support/help...hartpanels.htm ChartPanels, a collection of ChartPanel objects>
          https://ninjatrader.com/support/help...chartpanel.htm ChartPanel has a ChartScale object>

          Comment


            #6
            Hello ChrisL,

            After further inspection e.Source returns a ChartPanel object (NinjaTrader.Gui.Chart.ChartPanel). In this case, there would be no need to go through the collection of available chart panels as it gets it directly from the mouse event correct? For the appropriate XY conversion to time/price, use the chart scale from the panel obtained from the mouse click. The time/x variable remains the same, but the price/Y value depends on the panel.

            The question now is how do we tell the indicator to draw on a separate panel?

            Thanks
            Last edited by Unsuitable; 06-02-2022, 08:14 AM.
            Unsuitable
            NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

            Comment


              #7
              Hi Unsuitable, Any given indicator only "owns" one panel. We have no supported way for indicators to draw on panels that do not belong to them.

              Comment


                #8
                Hello ChrisL,

                That's what I was afraid of. Thanks for the back and forth. I'll do some more digging to see if there's anything or if it's possible in the first place. The other option would be to rewrite the entire code so the indicator its a proper drawing tool.
                Unsuitable
                NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                633 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                364 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                105 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                567 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                568 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X