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 timmbbo, Today, 08:59 AM
      2 responses
      10 views
      0 likes
      Last Post bltdavid  
      Started by alifarahani, Today, 09:40 AM
      6 responses
      40 views
      0 likes
      Last Post alifarahani  
      Started by Waxavi, Today, 02:10 AM
      1 response
      18 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by Kaledus, Today, 01:29 PM
      5 responses
      15 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by Waxavi, Today, 02:00 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Working...
      X