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.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by KirkHammett, Today, 11:15 PM
    0 responses
    3 views
    0 likes
    Last Post KirkHammett  
    Started by soon123, Today, 11:12 PM
    0 responses
    1 view
    0 likes
    Last Post soon123
    by soon123
     
    Started by JustinCross, Today, 09:48 PM
    0 responses
    8 views
    0 likes
    Last Post JustinCross  
    Started by Unsuitable, Today, 06:30 PM
    0 responses
    5 views
    0 likes
    Last Post Unsuitable  
    Started by michaelsh, Today, 04:28 PM
    0 responses
    6 views
    0 likes
    Last Post michaelsh  
    Working...
    X