Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator 'MyDrawRegionTest': Error on calling 'OnBarUpdate' method on bar 0: The cal

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

    Indicator 'MyDrawRegionTest': Error on calling 'OnBarUpdate' method on bar 0: The cal

    I think I need someone with some experience to help on this one...


    NT8 output window:

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



    It is the DrawRegion command that is the issue... I'm not sure if it's complaining about "this" or myDataSeries1/2.

    And I'm not sure which thread owns what where.

    I'm at a loss.


    Code:
    			Draw.Region(this, "Zone1", CurrentBar, 0, myDataSeries1, myDataSeries2, Zone_1_Border, Zone_1_Color,Opacity );
    Attached Files
    Last edited by sledge; 05-05-2015, 08:06 PM. Reason: adjusted title

    #2
    Does this work if you pass a Brush in to the Draw.Region() method directly, rather than the public brush you created?

    Code:
    Draw.Region(this, "Zone1", CurrentBar, 0, myDataSeries1, myDataSeries2, Brushes.Green, Brushes.LimeGreen, Opacity );
    MatthewNinjaTrader Product Management

    Comment


      #3
      Originally posted by NinjaTrader_Matthew View Post
      Does this work if you pass a Brush in to the Draw.Region() method directly, rather than the public brush you created?

      Code:
      Draw.Region(this, "Zone1", CurrentBar, 0, myDataSeries1, myDataSeries2, Brushes.Green, Brushes.LimeGreen, Opacity );
      I hard coded Brushes.Red instead and it no longer gives that error message.

      I'll work backwards from here.

      Comment


        #4
        Originally posted by sledge View Post
        I hard coded Brushes.Red instead and it no longer gives that error message.

        I'll work backwards from here.
        Try making the brush static.

        Comment


          #5
          I found VolumeZones which does it properly.

          I couldn't find a Draw.Region example in the standard examples, and got fixated on that with the error message.


          This fixes things..


          Zone_1_Color = Brushes.Green;
          Zone_1_Border = Brushes.LimeGreen;


          Now to fix the code because I have no region.

          Comment


            #6
            Originally posted by sledge View Post
            I found VolumeZones which does it properly.

            I couldn't find a Draw.Region example in the standard examples, and got fixated on that with the error message.


            This fixes things..


            Zone_1_Color = Brushes.Green;
            Zone_1_Border = Brushes.LimeGreen;


            Now to fix the code because I have no region.
            Interesting and strange. There does not seem to be any Intellisense for Brushes, or indeed anything in the SharpDX context. Does not even tell you if it is a namespace or a class. Hm.
            Last edited by koganam; 05-05-2015, 09:24 PM.

            Comment


              #7
              Originally posted by koganam View Post
              INteresting and strange. There does not seem to be any Intellisense for Brushes, or indeed anything in the SharpDX context. Does not even tell you if it is a namespace or a class. Hm.
              Which is why I panic'd and found some other stuff to try, as I figured I didn't have the right USING.

              See the other reported post in the bug section...

              Comment


                #8
                For the intelliprompt SharpDX and Media.Brushes stuff, we are looking into this further. This issue is tracked with NTEIGHT-8179 but not ETA on a resolution. In the mean time, Visual Studio will give you full intellisense support...

                Regarding the way you were creating a new SolidColorBrush(), this approach would work if you did that >= State.DataLoaded, since OnBarUpdate and the object would be running from the same thread at that point (your State.SetDefaults is running on the UI).

                Also if you still do not have a region, I think you need to swap your 0 and Current Bar arguments and it should work... I see that our documentation suggests the other way and that this used to work in NT7 so I will also have that checked out.
                MatthewNinjaTrader Product Management

                Comment


                  #9
                  Is there a recommended way of creating Brush from Color that avoids the pitfalls of the op's original approach (ie: new SolidColorBrush(Colors.LimeGreen))
                  Last edited by gregid; 05-06-2015, 05:19 PM.

                  Comment


                    #10
                    Originally posted by NinjaTrader_Matthew View Post

                    Also if you still do not have a region, I think you need to swap your 0 and Current Bar arguments and it should work... I see that our documentation suggests the other way and that this used to work in NT7 so I will also have that checked out.
                    It wasn't drawing until I moved my bars because of the bug in this post:



                    And opacity appears to be 0 to 100 now, not 0 to 10... so 5 was pretty light.

                    Comment


                      #11
                      Originally posted by sledge View Post
                      It wasn't drawing until I moved my bars because of the bug in this post:



                      And opacity appears to be 0 to 100 now, not 0 to 10... so 5 was pretty light.
                      Yes - you are right. And I can confirm that was fixed with the new @Regions DrawingTool which will be available in next built.

                      Also correct about opacity.
                      MatthewNinjaTrader Product Management

                      Comment


                        #12
                        Originally posted by gregid View Post
                        Is there a recommended way of creating Brush from Color that avoids the pitfalls of the op's original approach (ie: new SolidColorBrush(Colors.LimeGreen))
                        If you're just pushing a brush to the UI, you should just be able to use a predefined SolidColorBrush object

                        MyBrush = Brushes.LimeGreen;

                        If for any reason you need to create a new Brush object, you'll have to do that from something > State.Configure
                        MatthewNinjaTrader Product Management

                        Comment


                          #13
                          Originally posted by NinjaTrader_Matthew View Post
                          If you're just pushing a brush to the UI, you should just be able to use a predefined SolidColorBrush object

                          MyBrush = Brushes.LimeGreen;

                          If for any reason you need to create a new Brush object, you'll have to do that from something > State.Configure
                          Is it > State.Configure or >= State.Configure?

                          Comment


                            #14
                            > State.Configure.

                            You would want to make sure we're out of the configure state, which reside on the UI. So anything beyond State.Configure, such as DataLoad, Historical, etc.

                            Be aware that resources created in State.Configure are not disposed of here immediately and will be kept utilized by NS objects that are in grids (NS strategies in strategy grid) even if the object is not enabled.

                            Try to create resources in State.Historical or State.DataLoaded though some scenarios require the creation in State.Configure.
                            MatthewNinjaTrader Product Management

                            Comment


                              #15
                              [QUOTE=sledge;409688]I think I need someone with some experience to help on this one...


                              NT8 output window:

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


                              I have come across a similar situation.

                              This line of code compiles but sends the same error to output window when the indicator is loaded to a chart.

                              string BarHeight = Bars.BarsPeriod.Value.ToString();

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

                              .
                              RJay
                              NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by mmenigma, Today, 02:22 PM
                              1 response
                              3 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by frankthearm, Today, 09:08 AM
                              9 responses
                              35 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by NRITV, Today, 01:15 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post NRITV
                              by NRITV
                               
                              Started by maybeimnotrader, Yesterday, 05:46 PM
                              5 responses
                              26 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by quantismo, Yesterday, 05:13 PM
                              2 responses
                              21 views
                              0 likes
                              Last Post quantismo  
                              Working...
                              X