• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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,
        http://ninjatrader.com/support/helpG...rawobjects.htm

        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.

        http://www.screencast.com/t/mw1RoEwAA

        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 danitralla, Yesterday, 03:33 AM
              1 response
              18 views
              0 likes
              Last Post NinjaTrader_ShawnB  
              Started by ninjo, Yesterday, 11:54 AM
              0 responses
              6 views
              0 likes
              Last Post ninjo
              by ninjo
               
              Started by deblanka, Yesterday, 08:56 AM
              0 responses
              13 views
              0 likes
              Last Post deblanka  
              Started by Boonfly8, 03-22-2019, 12:30 PM
              7 responses
              24 views
              0 likes
              Last Post sledge
              by sledge
               
              Started by Sohal, Yesterday, 05:02 AM
              2 responses
              19 views
              0 likes
              Last Post techmint  
              Working...
              X