Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Addon getting the right ChartControl

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

    Addon getting the right ChartControl

    Hi,

    I'm developing a simple add-on following the documentation: https://ninjatrader.com/support/help...t_overview.htm


    The add-on I'm developing adds and removes certain drawings object to the chart through ChartControl. Below is a code snippet how I get to chart control


    Code:
    protected override void OnWindowCreated(Window window)
    		{
    			// Instantiate myChart by assigning a reference to the calling Window
    			if (window == null)
    			{
    				return;
    			}
    			myChart = window as Gui.Chart.Chart;
    		 	
    			if (myChart == null)
    			{
    			  return;
    			}
    			
    			chartControl = myChart.ActiveChartControl;
    			
    			if (chartControl == null)
    			{
    				return;
    			}
    
    			//find chart trader from myChart's Chart Control by its Automation ID: "ChartWindowChartTrader"
    			chartTrader = Window.GetWindow(myChart.ActiveChartControl.Parent).FindFirst("ChartWindowChartTraderControl") as Gui.Chart.ChartTrader;
    
    			if (chartTrader == null)
    			{
    			  return;
    			}
    ....
    When there is only 1 chart window opened, everything works perfectly. Then if there are 2 chart windows open, it seems I'm only getting the first ChartControl.

    To be specific, if there are two chart windows open, one shows AAPL and another GOOG. When trying to log the instrument name from chartControl.Instrument.FullName, the result would be AAPL and AAPL.

    Is there a identifier for chart windows that add-on can differentiate between them?

    Thanks

    #2
    Hi lkuo.me,

    This would be advanced but you would need to recognize the chart by the indicators on it. Or by having an indicator set a specific property you can recognize.

    Attached is an example originally created by NinjaTrader_Jesse that I have modified that demonstrates how to list the windows if they are charts, and how to list the indicators from each chart, and how to set a property in the indicator.

    Note, this example uses undocumented / unsupported code.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea. I will be looking into this.

      Thanks.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      571 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      330 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
      548 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      549 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X