Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 jeronymite, 04-12-2024, 04:26 PM
    3 responses
    40 views
    0 likes
    Last Post jeronymite  
    Started by bill2023, Today, 08:51 AM
    2 responses
    16 views
    0 likes
    Last Post bill2023  
    Started by sidlercom80, 10-28-2023, 08:49 AM
    167 responses
    2,260 views
    0 likes
    Last Post jeronymite  
    Started by warreng86, 11-10-2020, 02:04 PM
    7 responses
    1,362 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by Perr0Grande, Today, 08:16 PM
    0 responses
    5 views
    0 likes
    Last Post Perr0Grande  
    Working...
    X