Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Thread being used?

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

    Thread being used?

    Hi

    I have been using an indicator for 2 years in Ninjatrader, its open code but I have not changed anything.

    Suddenly last week it wont load and I get this message

    Indicator 'Juncuc': Error on calling 'OnBarUpdate' method on bar 0: The calling thread cannot access this object because a different thread owns it.

    Any Ideas please?


    #2
    It seems to be this causing it, when I change the colours in the inputs gui it works....

    Code:
    private Brush longColour=new SolidColorBrush( Color.FromRgb(15,90,180));//Brushes.Black;
    private Brush shortColour=new SolidColorBrush( Color.FromRgb(255,50,50));//Brushes.Black;
    any ides why?​

    Comment


      #3
      I have attached a picture, if I change in the inputs gui to this the error goes away and it loads...

      Comment


        #4
        Hello lucyjoy,

        Thanks for your post.

        A private brush would not be in the UI and changing a brush in the UI would not cause a threading error. It is likely some other code in the script is causing the threading error to occur.

        Are you making sure to set a default brush color in State.SetDefaults for public brushes in the script?

        This error could also occur if you are trying to get a SharpDX brush from a System.Windows.Media brush.

        Ultimately, you would need to reduce the script by commenting out code or add debugging prints to the script in OnBarUpdate() to determine exactly which line of code in OnBarUpdate() is throwing the threading error.

        Below is a link to a forum post that demonstrates how to use prints to understand behavior.

        https://ninjatrader.com/support/foru...121#post791121

        Let me know if I may assist further.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        581 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        338 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 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
        552 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X