Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

On state change method error

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

    On state change method error

    Hi, my indicator shows the below error:
    Error on calling "Onstatechange" method: The calling thread must be STA, because many UI components require this.
    my indicator uses addon dll file. Can you please tell, why the above error may be showing?

    #2
    Hello asmmbillah,

    Thank you for your post.

    So that we may accurately assist you, please provide the following information.
    • What is the name of the AddOn dll file?
    • Where did you get the AddOn .dll file from?
    • How are you setting up/calling the .dll file within your script?
    Thanks in advance, I look forward to your reply.
    <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


      #3
      Hello, good morning:
      I have the same error "Indicator 'SetIndicatorValueFromAddonWindowExample': Error on calling 'OnStateChange' method: The calling thread must be STA, because many UI components require this."

      The indicator and the addon are a NT8 exampleshowing how to launch an an addon from an indicator, from a button on it.

      I am trying to Launch the AddOn at the "OnstateChange" to apply it to my development which needs to launch the AddOn at early stages of an Indicator...
      I just move the lines where the addon were launch from the button click to the transition stage

      Code:
       else if (State == State.Transition)
      {
      // if (setIndicatorValueFromAddonWindowExampleToolsWindo w == null || setIndicatorValueFromAddonWindowExampleToolsWindow .IsVisible == false)
      // {
      Print("Before");
      setIndicatorValueFromAddonWindowExampleToolsWindow = new AddOns.SampleAddOns.SetIndicatorValueFromAddonWind owExampleToolsWindow();
      Print("after");
      // {
      // // set an internal property of the addon to this indicator to send information back
      // TargetIndicator = this
      // };
      // }
      // // open the window
      
      setIndicatorValueFromAddonWindowExampleToolsWindow .Show();
      // // bring to the top
      setIndicatorValueFromAddonWindowExampleToolsWindow .Activate();
      }
      Your help is highly appreciated
      Thank you
      Attached Files

      Comment


        #4
        Hello efeuvejota01,

        Thanks for your note.

        It seems that you may have reposted the original script created by my colleague Chelsea located in the forum thread linked below.



        That said, I see in the commented out code you posted that you are missing the use of a dispatcher for the UI in your script. This dispatcher is not missing from the attached file or the original indicator script.

        Please see the original script in the forum thread linked above which demonstrates using a dispatcher in the script.

        Also, see the help guide documentation below for more information about dispatchers.

        Multi-threading Condisterations for NinjaScript: https://ninjatrader.com/support/help...sub=dispatcher

        NinjaScript Best Practices: https://ninjatrader.com/support/help...sub=dispatcher

        Let us know if we 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
        600 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        346 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
        558 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        558 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X