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

processing mouse events

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

    processing mouse events

    Hello, i have an indicator A which draws on regions of a chart in the price/bar panel.

    The onRender of this indicator draws and fills areas of price in a grid.

    I have another indicator B which processes certain mouse events but when i try to click and process mouse events from B ... i am not getting a response. This is not an issue when i do not have A loaded.

    In the order they appear in the indicator panel A is first followed by B.

    Is there something i need to do or set in order for the chart behind the painted regions of A to be clickable.

    IsOverlay in A is set to true and SetZOrder set to -1

    thanks
    Last edited by soulfx; 08-23-2017, 07:04 AM.

    #2
    Hello soulfx,

    Thanks for writing in.

    Do you see this issue when applying the SampleCustomRender indicator to your chart instead of Indicator A?

    I created a video testing a strategy that takes mouse clicks to submit orders and I have attached the strategy to a chart with SampleCustomRender enabled.

    Demo: https://www.screencast.com/t/IHDgtUDu3X3

    I would suggest to take a look at the if(!IsInHitTest) section of the SampleCustomRender indicator to create the same behavior.

    Code:
    // Tip: This check is simply added to prevent the Indicator dialog menu from opening as a user clicks on the chart
    // The default behavior is to open the Indicator dialog menu if a user double clicks on the indicator
    // (i.e, the indicator falls within the RenderTarget "hit testing") 
    // You can remove this check if you want the default behavior implemented
    if (!IsInHitTest)
    {
    }


    I look forward to being of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hello, thanks jim for the video, didnt get a chance today will look at in morning and review and see if this is related to what i am doing

      thanks

      Comment


        #4
        Hello, ok in looking at this, i see it is not an IsInHitTest issue - even with trying this out.

        In terms of SetZOrder where ChartBars default value is 1 from the help page.
        The situation is i have 2 main indicators.
        One of which i set SetOrder to -1 indicator A
        I then have indicator B - which tries to draw behind the chart bars by checking the minimum ZOrder in the chart objects.
        However i am actually painting in onrender my own custom bars and i just set the Zorder in the state management Historical state to 2 .... so i can then set drawing tool component within my indicator to 1.
        But even doing this it is still going behind indicator A and thus i cannot see the drawing.

        The key being i want my custom drawing in the indicator behind the chart bars but in front of the drawing in indicator A - even switching the order in indicator panel doesnt seek to affect.

        I put in a print statement where i check the minimum ZOrder before setting it for indicator B drawing tool component and it is -1. So by setting it to 1 should it now appear now in front of indicator A?

        Perhaps there is a conflict with trying to set my drawing tool to 1 ?

        So aside from this - how does one change the default chart bars zorder if they were not drawing own candles/bars? As it doesnt leave much room if you have several indicators you wish to draw behind the candle/bars?

        So i am trying various permutations here and not getting the desired effect.

        Indicator A at the back

        Indicator B at the front with the candles i draw in onrender and then custom drawing tool to be beind these bars but in front of indicator A.

        If one tries to set two indicators to -1 does the order in the indicator panel they are added matter?

        let me know if anything i am not seeing here or other approach to take

        thanks

        Comment


          #5
          Hello soulfx,

          I would advise to visualize each component of your suite to be a layer so you can easily manage the appearance through the ZOrder. Creating an indicator to control items that should be in a different layer would be the best way to manage this.

          Going more into detail, I would suggest to use -1 for your back most layer and then to use int.MaxValue and int.MaxValue-1 for your top most and second top most layers. Your custom drawing objects should then be placed below these top two layers and in front of your back most indicator.

          As it is not advised to set ZOrder directly, I would suggest to treat ChartBars as your "base" layer and treat everything else by adding layers to the top or bottom.

          During my own tests, I am seeing some strange behavior with assigning ZOrders that I am looking into further with my colleagues.

          If you have any other questions for me in the meantime, please don't hesitate to ask.
          JimNinjaTrader Customer Service

          Comment


            #6
            Hello, im not sure i follow how your advice is any different to what i am doing.

            Already seeing the indicators as layers and the backmost one IS set to -1
            I explained how i am trying to set the other 2.
            Regarding not advised to Set ZOrder directly - NInja provide a method to do so and it appears it does not work - i already recall reading other postings on Zorder not acting as expected and you are yourself experiencing unexpected results. Please share once you check your own tests.

            For now ZOrder does not do what it says on the tin - if not advised then it should not be offered by ninja and explained it is unsupported or that development arent clear on how to offer it as a robust working UI element for gui design.

            thanks

            Comment


              #7
              Hello soulfx,

              I received your note.

              I don't know what else you would like me to do at this time. I have observed behavior in my own tests that I believe you see as well and have in question. I do not know what else you want me to test.

              I am looking into the matter further and I have no other information available right now.

              Was there something else you wanted me to look into regarding ZOrder?
              JimNinjaTrader Customer Service

              Comment


                #8
                Hello, thats all i needed to know - just wanted to confirm there is an issue with this and you are awaiting information or suggestions from development for another approach?

                Ie what i am trying to effect is not working?

                thanks

                Comment


                  #9
                  Hello soulfx,

                  Yes, as I saw and tried to replicate, there was an issue preventing me from coming up with the desired effect.

                  To be more accurate, it appears that large ZOrder values which are used to bring things to the front can be ignored when the ZOrder is converted from a desired value to an actual value to be used.

                  This issue is being tracked with the ticket ID: NTEIGHT-12067.

                  Also, I submitted a vote on your behalf tracking interest in being able to have NinjaScripts store their ZOrders properly when reloading with F5. This is a design limitation and is being tracked differently. This tracking number can be found with SFT-1977.

                  These can be found in the Release Notes page of NinjaTrader 8 when a version with a fix becomes available/the feature request is fulfilled.

                  Release Notes: https://ninjatrader.com/support/help...ease_notes.htm

                  I don't have a workaround I can suggest. If you would like to check after some time passes for a fix to be ready, I can send you a nightly build that has a fix applied if you would like to test it before a release includes it.

                  If there is anything else I can do in the meantime, please let me know.
                  JimNinjaTrader Customer Service

                  Comment


                    #10
                    Just curious on progress if any / status of this

                    Hello just curious on the progress if any // status of this ZOrder issue

                    Comment


                      #11
                      Hello soulfx,

                      Thank you for your response.

                      The documentation on SetZOrder was updated to reflect the proper means to set the top most object. Please visit the following link for the documentation: https://ninjatrader.com/support/help...?setzorder.htm

                      int.MaxValue sets the Z-Order to the current max + 1. This means if you want to have an object be the top most then it should be set with int.MaxValue last.

                      To find the current Chart's max Z-Order please use ChartPanel.ChartObjects.Max(co => co.ZOrder).

                      Please let me know if you have any questions.

                      Comment


                        #12
                        Hello, finally getting a chance to test this out -

                        Im not sure if you read the whole thread and the issue Jim was having - other than a doc update has anything changed.

                        More specifically now i have a custom drawing tool that uses the drawing tool properties

                        ZOrderType = DrawingToolZOrder.AlwaysDrawnLast;

                        and then using ZOrder = ChartPanel.ChartObjects.Max(z => z.ZOrder) + 1;

                        this i am trying to set in OnRender in the drawing tool depending on some other context.

                        So i am either setting it to the above or ZOrderType = DrawingToolZOrder.AlwaysDrawnFirst;

                        - it is initialised in SetDefaults state of the OnStateChange

                        the code is accessing where i try to switch the Type in OnRender - but is doesnt seem to be changing.

                        The point being i am trying to use this when i want my custom drawing in the foreground instead of the background in certain conditions and vice versa.

                        So following on from below it 'appears' the use of ZOrder is limited or not functioning.

                        Note this is separate to the SetZOrder discussed below

                        please advise

                        thanks

                        Comment


                          #13
                          Hello soulfx,

                          Thanks for writing back to this thread.

                          It would not be advised to set the ZOrder property of a NinjaScript to change an objects ZOrder. It would instead be advised to use SetZOrder() to change the ZOrder index used by the NinjaScript. You can reference the ZOrder property documentation to see this advisory note.

                          ZOrder (publicly available) - https://ninjatrader.com/support/help...art_zorder.htm

                          When we last visited this issue, the observed behavior with SetZOrder() was not matching the help guide, and the help guide was since changed to reflect the expected behavior.

                          As you are stating the issue now has to do with ZOrderType, could you provide a simple example that shows how you are encountering this issue, bearing in mind that it would be advised to use SetZOrder() over setting the ZOrder property?
                          JimNinjaTrader Customer Service

                          Comment


                            #14
                            Hello, can you confirm and clarify what you mean in post #5 where you state to not use SetZorder explicity ... then in this post you advocate its use.

                            The ZOrderType which is also in the help manual i was trying to use this in the drawing tool for which it is designed ... are you saying is ok to use this ? but to not set ZOrder explicitly ie
                            ZOrder = -1 or other value?

                            thanks

                            Comment


                              #15
                              Hello soulfx,

                              In post #5, I was referring to directly changing the ZOrder property of a NinjaScript being invalid. SetZOrder() would still be the suggested method to use to modify ZOrders.

                              Through a custom DrawingTool, you could set the ZOrderType within State.SetDefaults in OnStateChange().

                              From an indicator, you can adjust the ZOrder with SetZOrder() in State.Historical.

                              The ZOrderType which is also in the help manual i was trying to use this in the drawing tool for which it is designed ... are you saying is ok to use this ? but to not set ZOrder explicitly ie
                              ZOrder = -1 or other value?
                              Yes, using ZOrderType in a DrawingTool is valid. Changing ZOrder should be done with SetZOrder() and not by setting the ZOrder property.
                              JimNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by nandhumca, Yesterday, 03:41 PM
                              1 response
                              12 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by The_Sec, Yesterday, 03:37 PM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by vecnopus, Today, 06:15 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post vecnopus  
                              Started by Aviram Y, Today, 05:29 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post Aviram Y  
                              Started by quantismo, 04-17-2024, 05:13 PM
                              3 responses
                              27 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X