Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ChartControl safe indicator state?

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

    ChartControl safe indicator state?

    Is there a way to know a safe state of a chartcontrol?

    I need to use ChartControl.Dispatch.Invoke to get some UI details, but when multiple workspsaces with multiple charts with multiple tabs load at once, invoking in DataLoaded state can freeze the whole platform. I thought DataLoaded to be safe for ChartControl checks, but it seems not to be the case. How can I know it reached a stable state? (I don't know how to call this, ChartControl is not null, obviously data is loaded, still Invokes freeze).

    Are indicator states in direct connection with UI state at all or its rather only data related. If latter, is there a way to know about UI state?

    #2
    Hello Zapzap,

    From the help guide:
    "As a best practice, you should always make sure to use Dispatcher.InvokeAsync() to ensure your action is done asynchronously to any internal NinjaTrader actions. Calling the synchronous Dispatcher.Invoke() method can potentially result in a deadlock scenarios as your script is loaded."



    If the ChartControl is not null, then it can be used. But with a script in any state using Dispatcher.Invoke() will cause deadlocks.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Okay, then how can I return a value?

      Or: it is only an issue while charts are loading. How do I know that I can use Invoke? (chart finished loading)
      Last edited by Zapzap; 10-30-2019, 09:49 AM.

      Comment


        #4
        Not that value, sorry. I have multiple-chart indicators communicating with each other, and sometimes one needs some data (like PersistanceId, tab name etc..) from the other's ChartControl, so I Invoke to get the value. It's never an issue when the charts are already loaded only when NT is starting and the charts are being created (as if DataLoaded and ChartControl != null could be reached without a render ready control).
        This is why I am asking if there's a way to know when a ChartControl is in a state when it can be called synchronously.
        But according to that note, well, I guess I'll need to move the whole block to the async call then.

        Comment


          #5
          Hi Zapzap,

          Disregard my deleted post. That was intended for another thread.
          Apologies.

          May I confirm you are using InvokeAsync and not Invoke?

          You can use this ChartControl.Dispatcher.InvokeAsync() once ChartControl is not null.

          Then you can call (and sometimes set) ChartControl properties or make modifications to the WPF elements of the chart.

          The ChartControl will be initialized by State.DataLoaded if the script is added to a chart.

          There is not a time the ChartControl can be accessed synchronously.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Chelsea,

            Thanks for your replies.

            What about DispatcherOperation<bool> result = ChartControl.Dispatcher.InvokeAsync(...) ?
            if I am checking for the result object (like if (result != null), it sometimes also locks up.

            Comment


              #7
              Hello Zapzap,

              May I have a reduced simple demonstration test script?

              To export a NinjaTrader 8 NinjaScript so this can be shared and imported by the recipient do the following:
              1. Click Tools -> Export -> NinjaScript...
              2. Click the 'add' link -> check the box(es) for the script(s) and reference(s) you want to include
              3. Click the 'Export' button
              4. Enter a unique name for the file in the value for 'File name:'
              5. Choose a save location -> click Save
              6. Click OK to clear the export location message
              By default your exported file will be in the following location:
              • (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>
              Below is a link to the help guide on Exporting NinjaScripts.
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              579 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              334 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              554 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              551 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X