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 helpwanted, Today, 03:06 AM
    1 response
    12 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    9 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    5 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    242 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    387 views
    1 like
    Last Post Gavini
    by Gavini
     
    Working...
    X