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

Drawing Tool Event Sequence Help

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

    Drawing Tool Event Sequence Help

    Hello!

    I have a custom indicator and once it's placed on a chart, I need to move the EndAnchor if the user modifies a custom property.

    I'm trying to understand the best event/method where this logic should be place.
    That is, what event is triggered after the user closes the properties dialog?

    Is there information on the sequence of events for this?

    Thanks in advance!

    #2
    I'm not sure if this is proper, but what I ended up doing is setting a flag to denote when the property has changed.

    If it did then I can update my EndAnchor within OnRender() via the EndAnchor.UpdateFromPoint() method. And then, I can redraw the tool.

    I'm not sure if that is the best way to handle this, but it works.

    Comment


      #3
      Hello MarkWise,

      Thank you for writing to the support team.

      I am reviewing your inquiry and will be back with a reply shortly.

      I look forward to assisting further.
      Chris L.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by MarkWise View Post
        Hello!
        That is, what event is triggered after the user closes the properties dialog?
        Is there information on the sequence of events for this?
        Would that be properties dialog for the indicator or drawing tool? I am working on a solution for a somewhat similar issue. My issue is detecting by code when a custom drawing tool has been deleted. I have been able to determine by code when a custom drawing tool has been edited so I can update some data files. But no luck on when a drawing tool has been deleted.

        Comment


          #5
          Exactly... When the user edits a drawing tool's properties, how can one tell if the values have been applied (by closing the dialog or clicking the Apply button)?

          I feel my workaround was a bit "hacky" so I'm curious to know if there is a proper solution to this.

          Regarding the deletion, could you put code in the OnStateChange() event when State == Terminated?

          Comment


            #6
            If I can create a solution I will pass it along. My code for detecting an edit is a little tacky also so that may be are only option for now . I have made a suggestion to create a method for a drawing tool to be used in On Terminated such as a bool IsDrawingToolEdited(this.Tag) and IsDrawingToolDeleted(this.Tag) which would solve all our ills.

            Comment


              #7
              Hello MarkWise,

              Thank you for your patience on this.

              We would recommend just calling the Draw for the object again with the updated values from the parameters. There is no need to use OnRender. You could use the ChartAnchors manipulation methods as an alternative. You would call these methods from your main indicator logic as well. The lifecycle of NinjaScript will ensure that the drawings get updated.

              More on ChartAnchor here:


              @TAJTrades
              I will have to follow up with you tomorrow on your question.

              Please let us know if we may be of any further assistance.
              Last edited by NinjaTrader_ChrisL; 09-01-2017, 12:39 PM.
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                Thanks for the reply Chris.

                I'm not sure calling Draw would help in this case, due to the nature of what I'm trying to accomplish.

                Comment


                  #9
                  If you haven't already done so you might want to drop this line of code in every OnStateChange() of your DrawingTool . Do this for all your custom drawing tools.

                  NinjaTrader.Code.Output.Processing(string.Format(" {0} {1,20} State: {2}", this.Name, this.Tag, this.State), PrintTo.OutputTab1);

                  If you wanted you could also include some varibales for tracking. What you will find is how NT8 loops thru all drawing objects not just the one that was edited and how many times each draw object was looped. That is not a bad thing because for one it should be checking for duplicate Tag names. However it creates a nightmare when trying to determine which draw object was Edited or Deleted. Determining if a new draw object was created can be determined by when the final MouseDown of the drawing sequence.

                  This brings it back to NT8 needs a simple bool flag to check for which draw object was just Edited or Deleted. Something like:

                  bool IsEditing
                  bool IsDeleting

                  Since it appears that all events flow thru State = State.Terminated the bool can be checked there. If the bool is evaluates to true then imagination is the only constraint. You remove custom events, update global variables, edit custom data file, maybe even alert your smart phone to order lunch.........

                  Other than that I am all out of ideas. I am open to any, ANY!, solution. If you have one please share.

                  Comment


                    #10
                    Hello TAJTrades,

                    Thanks for the post.

                    Currently, there is not a method for checking if the drawing object has been removed. The OnRender() method will be called when a drawing object is removed from the chart. You could check the ChartObjects inside of OnRender() and check for the drawing object that was removed. There is an example use case in this help guide link about ChartObjects.


                    Please let us know if we may be of any further assistance.
                    Chris L.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks Chris. I over looked that one. I will give it a shot this weekend.

                      Would it be possible to submit a request to have something like IsEdited and IsDeleted methods added to NT8? Sure would make life a lot easier for those of us more into chart drawing than indicator development and should not be a complex development issue.

                      Comment


                        #12
                        Hello TAJTrades,

                        Thanks for the follow-up.

                        I will submit a feature request to have this method added. Thank you for the input.
                        Chris L.NinjaTrader Customer Service

                        Comment


                          #13
                          Hello,

                          I have the feature tracking number for you.

                          SFT-2682
                          Chris L.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by RubenCazorla, Today, 09:07 AM
                          0 responses
                          1 view
                          0 likes
                          Last Post RubenCazorla  
                          Started by BarzTrading, Today, 07:25 AM
                          2 responses
                          28 views
                          1 like
                          Last Post BarzTrading  
                          Started by devatechnologies, 04-14-2024, 02:58 PM
                          3 responses
                          20 views
                          0 likes
                          Last Post NinjaTrader_BrandonH  
                          Started by tkaboris, Today, 08:01 AM
                          0 responses
                          6 views
                          0 likes
                          Last Post tkaboris  
                          Started by EB Worx, 04-04-2023, 02:34 AM
                          7 responses
                          165 views
                          0 likes
                          Last Post VFI26
                          by VFI26
                           
                          Working...
                          X