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

Issues displaying real time data in a XAML textbox

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

    Issues displaying real time data in a XAML textbox

    Hello NT team,
    I was wondering if you could help me out to clarify how to display real time values from an indicator to a XAML textbox in an Addon.
    I have an indicator that reads values from an account, these values are then shared with an addon via a Property. This is working fine, the updated values from the indicator are available within the addon.
    The addon has a XAML textbox that should display the values every time they change. To do that I have implemented two ways:
    1. A buttonclick() method, when clicked, a string variable linked to the XAML textbox is assigned the updated value, and then displayed in the textbox. That´s working fine.
    2. The Property in the Addon also has registered an event that triggers every time the values change in the indicator, these values are assigned to the same string variable of the XAML textbox. I was expecting the updated value to appear automatically in the textbox, but it doesn´t do it. The event trigger of the Addon works because I see the updated values in the output window by doing a PrintTo.OutputTab1. However, I cannot make that same value to show in the XAML textbox. It only shows in the textbox when pressing the button (point 1 above).
    I thought of an explanation that the XAML textbox runs in a different thread, when the button is pressed the system would give it priority and displays the updated value in the textbox, however that´s not happening with a registered event (point 2 above) because of perhaps I have to consider threading? Then, I used Dispatcher.InvokeAsync inside the event trigger method and assign the updated value already available to the string variable of the textbox, but still does not work and nothing is shown in the textbox.

    Can you give me some guidance of what could be the issue and have a working example that I can have a look at?
    Many thanks!


    #2
    Hello juartur,

    Once the xaml is parsed the objects are created as WPF objects.

    The window dispatcher should be used (with an InvokeAsync) to modify the UI thread from the Account thread.

    I've modified the AddonShell to demonstrate.
    AccountAddonTest_NT8.zip
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      It works now! your example clarified it all, "this." in front of Dispatcher made the trick

      Thanks a lot!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by futtrader, 04-21-2024, 01:50 AM
      4 responses
      41 views
      0 likes
      Last Post futtrader  
      Started by Option Whisperer, Today, 09:55 AM
      1 response
      11 views
      0 likes
      Last Post bltdavid  
      Started by port119, Today, 02:43 PM
      0 responses
      3 views
      0 likes
      Last Post port119
      by port119
       
      Started by Philippe56140, Today, 02:35 PM
      0 responses
      4 views
      0 likes
      Last Post Philippe56140  
      Started by 00nevest, Today, 02:27 PM
      0 responses
      2 views
      0 likes
      Last Post 00nevest  
      Working...
      X