Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to Find Selected Instrument in Chart Trader

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

    How to Find Selected Instrument in Chart Trader

    Creating Custom Buttons for Chart Trader.

    How do I find the Instrument that is selected for the Chart/Chart Trader?

    I figured out how to find the selected account for Chart Trader. Using the same approached I can not find the instrument.

    Code:
    AccountSelector accountSelector = Window.GetWindow(ChartControl.Parent).FindFirst("ChartTraderControlAccountSelector") as AccountSelector;
    Print(accountSelector.SelectedAccount.ToString());
    InstrumentSelector instrumentSelector = Window.GetWindow(ChartControl.Parent).FindFirst("ChartTraderControlInstrumentSelector") as InstrumentSelector;
    Print("insturment: " + instrumentSelector.Instrument.ToString());
    Last edited by DoctorPurpleApe; 03-18-2022, 09:17 AM. Reason: Removed random space in ChartTrader..., was C hartTrader...

    #2
    Hello DoctorPurpleApe,

    Thank you for your note.

    You're definitely on the right track there.

    I'm attaching a simple example indicator that finds the InstrumentSelector and prints the current instrument to the log.

    Please let us know if we may be of further assistance to you.
    Attached Files

    Comment


      #3
      Thank you so much for the code. Changed the FindFirst parameter to "ChartWindowInstrumentSelector" and it worked great.

      The comment //You have to put the stuff below within this ChartControl.Dispatcher.InvokeAsync((Action)(() =>, because you are trying to access something on a different thread. actually helped solved a new problem I had with my code, so I am really glad you attached the file.

      Comment


        #4
        Will this work if you have multiple TABs in a chart, or will it always default to the first chart?

        Comment


          #5
          Hello MisterTee,

          Thank you for your note.

          I tested this indicator on a chart with multiple tabs and it seemed to print the instrument on the tab where I applied the indicator, even if it wasn't the first tab in the chart window. If there is something more specific you are looking to achieve, please let us know and we would be glad to provide additional resources to assist.

          Thank you for your patience.

          Comment


            #6
            thank you!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Hwop38, 05-04-2026, 07:02 PM
            0 responses
            154 views
            0 likes
            Last Post Hwop38
            by Hwop38
             
            Started by CaptainJack, 04-24-2026, 11:07 PM
            0 responses
            306 views
            0 likes
            Last Post CaptainJack  
            Started by Mindset, 04-21-2026, 06:46 AM
            0 responses
            244 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            345 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            176 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Working...
            X