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

Any way to access the unique ID (identifier) of chart window?

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

    Any way to access the unique ID (identifier) of chart window?

    In NT7 i remember i used a property like ChartHandleId or whatever, so, I saved each chart's identified in c# dictionary.
    What is the alternative in NT8 ? lets say, I want to get the unqinue identifiers for each opened charts and then save some values along with those identifiers in dictionaries.

    I tried this:
    ChartPanel.GetHashCode().ToString()

    but it still give different identifiers from two indicators attached (on different panels) on same chart

    #2
    Found them myself. These seems to be some kind of identifiers, unique for windows (with multiple indicators/sub-charts in them):


    Code:
    ChartControl.OwnerChart.Form.Handle); //same as: ChartControl.OwnerChart.Form.Handle.GetHashCode();
    ChartControl.OwnerChart.GetHashCode()
    ChartControl.Parent.GetHashCode()
    these were not usable for me:

    Code:
    Owner --- null
    ChartPanel.Parent -- ChartControl object
    ChartControl.OwnerChart.Name --- calling thread cant access this
    ChartControl.OwnerChart.TabIndex --- calling thread cant access this
    ChartControl.OwnerChart.Tag --- calling thread cant access this
    ChartControl.OwnerChart.Uid ---calling thread cant access this
    ChartControl.OwnerChart.Parent --> NULL
    ChartControl.OwnerChart.Owner --calling thread cant access this
    Last edited by ttodua; 08-26-2019, 01:19 PM.

    Comment


      #3
      Get tab or window id

      In an indicator call from State.configure. Will return either the window or tab guid.

      Code:
      public enum IdTw {Tab,Window}
      
      protected string GetChartId(IdTw IdType)
      {[INDENT]string Identifier = "";
      Chart chartWindow = Window.GetWindow(ChartControl.Parent) as Chart;
      chartWindow.Dispatcher.Invoke((Action)(() => {[/INDENT][INDENT=2]if (IdType == IdTw.Tab)
      {[/INDENT][INDENT=3]TabItem t = chartWindow.MainTabControl.SelectedItem as TabItem;
      ChartTab TabMe = t.Content as ChartTab;
      Identifier = TabMe.PersistenceId;[/INDENT][INDENT=2]}
      if (IdType == IdTw.Window)
      {[/INDENT][INDENT=3]IWorkspacePersistence winPer = chartWindow as IWorkspacePersistence;
      Identifier = winPer.WorkspaceOptions.PersistenceId;[/INDENT][INDENT=2]}[/INDENT][INDENT]}));
      
      return Identifier;[/INDENT]
        }

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Jimmyk, 01-26-2018, 05:19 AM
      6 responses
      835 views
      0 likes
      Last Post emuns
      by emuns
       
      Started by jxs_xrj, 01-12-2020, 09:49 AM
      6 responses
      3,291 views
      1 like
      Last Post jgualdronc  
      Started by Touch-Ups, Today, 10:36 AM
      0 responses
      10 views
      0 likes
      Last Post Touch-Ups  
      Started by geddyisodin, 04-25-2024, 05:20 AM
      11 responses
      62 views
      0 likes
      Last Post halgo_boulder  
      Started by Option Whisperer, Today, 09:55 AM
      0 responses
      9 views
      0 likes
      Last Post Option Whisperer  
      Working...
      X