Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Updating PlotBrushes

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

    Updating PlotBrushes

    Hi,
    How do i correctly update PlotBrushes? Samples indicate that i can just set them in OnbarUpdate, however this does not always work. For example, if i use my indicator as an input to another indicator then i get "Indicator 'MyIndicator': Error on calling 'OnBarUpdate' method on bar 0: The calling thread cannot access this object because a different thread owns it." error. Using Dispatcher.Invoke makes things very slow. Using Dispatcher.InvokeAsync seems to apply color to the wrong bar, no matter how i try to do it (probably my mistake, but still it is not clear how to do it correctly).
    Last edited by rokups; 11-01-2024, 06:03 AM.

    #2
    Hello rokups,

    What specific code are you trying to execute and where is it being executed from in that use case? Do you have a sample that you can provide?
    JesseNinjaTrader Customer Service

    Comment


      #3
      I modified MACD indicator to display a colored histogram. See attached file.
      Attached Files

      Comment


        #4
        Hello rokups,

        You need to freeze the brushes you are making. You can read about using brushes in the link below, from that link:
        Warning: If you do not call .Freeze() on a custom defined brush WILL eventually result in threading errors should you try to modify or access that brush after it is defined.
        Note: Anytime you create a custom brush that will be used by NinjaTrader rendering it must be frozen using the .Freeze() method due to the multi-threaded nature of NinjaTrader.


        JesseNinjaTrader Customer Service

        Comment


          #5
          Seems to work. Thank you.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Marty125, Today, 11:14 AM
          4 responses
          16 views
          0 likes
          Last Post Marty125  
          Started by markpk1, Today, 11:54 AM
          0 responses
          4 views
          0 likes
          Last Post markpk1
          by markpk1
           
          Started by Carlos19, Today, 10:15 AM
          2 responses
          10 views
          0 likes
          Last Post Carlos19  
          Started by markdshark, 04-16-2023, 09:29 AM
          6 responses
          232 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by siddhugaddi, Today, 10:31 AM
          2 responses
          15 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X