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

Enact Drawing Tool Rectangle

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

    Enact Drawing Tool Rectangle

    I have been looking for how to enact the drawing tool for a rectangle from within an indicator, but have it attached to the indicator and control over the drawing template

    ChartControl.TryStartDrawing("NinjaTrader.NinjaScr ipt.DrawingTools.Rectangle");

    I have used that line of code, but it just draws a normal rectangle attached to the chart/instrument.

    Any ideas?

    #2
    Hello trader3419, and thank you for your question.

    To attach a rectangle to an indicator, you just need to feed values from your indicator into the rectangle's arguments. This code sample should help. Please let us know if there are any other questions we could answer.

    We will use this syntax from the help guide.

    Originally posted by http://ninjatrader.com/support/helpGuides/nt7/drawrectangle.htm
    DrawRectangle(string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, Color color)
    DrawRectangle(string tag, bool autoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, Color color, Color areaColor, int areaOpacity)
    DrawRectangle(string tag, bool autoScale, DateTime startTime, double startY, DateTime endTime, double endY, Color color, Color areaColor, int areaOpacity)
    Code

    Code:
    [FONT=Courier New]int width=3, height=3;[/FONT]
    [FONT=Courier New]DrawRectangle("MyRectangle", -width, Values[0][0], 0, Values[0][0] + height, Color.ForestGreen);[/FONT]
    You will want that code at the end of your OnBarUpdate method.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Thank you Jessica.

      Although I want to enact the drawing tool, not just draw the rectangle. How might I do that, while having the rectangle the user draws, attached to my indicator.

      Comment


        #4
        The feature you are describing was a new feature added to NinjaTrader 8. In order to do what you are describing you will need to upgrade to that platform. When you have, these help guide links will have more information.

        Programmatically, through NinjaScript, we may use anchors



        By hand, we can draw objects on charts and attach them to indicators as well, check out "snap mode"

        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Thanks Jessica.
          Awesome Response

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by zstheorist, Today, 07:52 PM
          0 responses
          6 views
          0 likes
          Last Post zstheorist  
          Started by pmachiraju, 11-01-2023, 04:46 AM
          8 responses
          150 views
          0 likes
          Last Post rehmans
          by rehmans
           
          Started by mattbsea, Today, 05:44 PM
          0 responses
          6 views
          0 likes
          Last Post mattbsea  
          Started by RideMe, 04-07-2024, 04:54 PM
          6 responses
          33 views
          0 likes
          Last Post RideMe
          by RideMe
           
          Started by tkaboris, Today, 05:13 PM
          0 responses
          6 views
          0 likes
          Last Post tkaboris  
          Working...
          X