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

Custom DrawingTool Question

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

    Custom DrawingTool Question

    Hello!

    Is it possible to have a drawing object automatically sited on the chart using pre-defined anchor locations?

    For example,when the user chooses to draw a rectangle, as soon as the Rectangle tool is selected, it would appear at a pre-defined location on the chart so that the user doesn't have to drag/drop the anchors.

    I was thinking that the StartAnchor, MiddleAnchor, and EndAnchor could be created with the necessary Time/Price values as needed within the OnStateChange() event (and the state set to Normal.)

    Later, if the user wanted to move/edit the tool, the rest of the interaction would behave as normal.

    Is this possible?

    #2
    Hello MarkWise,

    Thank you for your note.

    Yes, it is possible to have a button on a chart which will draw a Rectangle at a predefined location. I have put together a sample which when you apply the indicator ChartSideBarButton1DrawsRectangleBut2RemovesRec to a chart and click button 1, you'll see a rectangle drawn 10 bars back.

    Please let us know if you need further assistance.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      That's a great start, but not quite what I need. I'd like to be able to dynamically add a Drawing Tool object.

      Additionally, the user needs to be able to then interact with the object (move it, change the anchor points, delete it, etc.)

      I was hoping to be able to create a new subclass/tool by inheriting from the ShapeBase object.

      Using code, something like this:

      Code:
          public class CustomShape : ShapeBase
          {
              protected override void OnStateChange()
              {
                  base.OnStateChange();
      
                  if (State == State.SetDefaults)
                  {
                      Name = "CustomShape";
                      ShapeType = ChartShapeType.Rectangle;
                  }
                  else if (State == State.DataLoaded)
                  {
                      DrawingState = DrawingState.Normal; // ??? What would this need to be?
      
                      StartAnchor.Price = 142.80;      // TODO - Detemine prices here
                      MiddleAnchor.Price = 141.60;
      
                      // Other properties needed here???
                  }
              }
          }

      Does that make sense? Is this possible?

      Comment


        #4
        Hello MarkWise,

        You could look for manually drawn objects, then modify them. For an example of this see the looping example a the following link,


        Or if you wanted to create a custom tool based off an existing tool, you could see the following video for an example of how to go about doing that.

        Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Perfect!

          That's exactly what I'm looking for. It looks like I can create my own Rectangle hybrid class,with qualities from the ChartMarker objects as well to implement what I need.

          Thanks for all of your help!

          Comment


            #6
            Originally posted by MarkWise View Post
            Hello!

            Is it possible to have a drawing object automatically sited on the chart using pre-defined anchor locations?

            For example,when the user chooses to draw a rectangle, as soon as the Rectangle tool is selected, it would appear at a pre-defined location on the chart so that the user doesn't have to drag/drop the anchors.

            I was thinking that the StartAnchor, MiddleAnchor, and EndAnchor could be created with the necessary Time/Price values as needed within the OnStateChange() event (and the state set to Normal.)

            Later, if the user wanted to move/edit the tool, the rest of the interaction would behave as normal.

            Is this possible?
            Cool! Perhaps placing the button inside the main tool bar instead of on side would save some chart real estate.

            Also using a default draw tool object (i.e.Square) would provide a one click draw where the user can determine the anchors as he wishes.

            Cheers!

            Comment


              #7
              I actually created a hybrid of the Rectangle tool and modified it so that it only needs one starting anchor to be rendered during the MouseDown event. The other anchor is calculated internally.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by yertle, Yesterday, 08:38 AM
              7 responses
              28 views
              0 likes
              Last Post yertle
              by yertle
               
              Started by bmartz, 03-12-2024, 06:12 AM
              2 responses
              21 views
              0 likes
              Last Post bmartz
              by bmartz
               
              Started by funk10101, Today, 12:02 AM
              0 responses
              5 views
              0 likes
              Last Post funk10101  
              Started by gravdigaz6, Yesterday, 11:40 PM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by MarianApalaghiei, Yesterday, 10:49 PM
              3 responses
              11 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Working...
              X