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

Movable objects

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

    Movable objects

    Is it possible for an indicator to be manipulated on a chart in real-time by the user? For example, if I have an indicator which simply draws a box in a specified location on a chart, is is possible within Ninjascript for a user to be able to the change the dimensions of that box, move it around, etc, in real-time, directly on the chart (without opening the indicator properties)? Thanks.

    #2
    Hello,


    Thank you for your note.


    It is only with DrawObjects that have been unlocked for manual move by the strategy that created the Drawing object that you can move it by hand.



    This can be done by setting the drawObject locked property to false.

    Let me know if I can be of further assistance.

    Comment


      #3
      Thanks for your reply. I'm having trouble though, when I try this bit of code (taken directly from the help guide), I get "The type or namespace name 'IRectangle' could not be found."

      PHP Code:
      protected override void OnBarUpdate() 
      {
           
      IRectangle rectangle DrawRectangle("tag1"false10Low[10] - TickSize5High[5] + TickSizeColor.PaleGreenColor.PaleGreen2);

      Comment


        #4
        Hello,

        When I put this in a NinjaTrader indicator it compiles for me no problem.

        Do you have some other line by chance that might be causing issue?

        -Brett

        Comment


          #5
          Can this only be used in an indicator? I can get it to work just fine within an indicator (the unlocking works as expected as well), but in a strategy it always gives me that error.

          Edit: Never mind....I can get it to work if I create a new blank strategy, just not in the strategy that I want to put it in. Oh well, I'll keep trying.

          Edit 2: OK, I think I figured it out.

          Thanks again for your suggestions, this does exactly what I wanted.
          Last edited by Radical; 12-02-2011, 03:23 PM.

          Comment


            #6
            Hello,

            Excellent. Glad you got it working.

            -Brett

            Comment


              #7
              Upon further testing, I've discovered another small problem. It seems that with each bar update the drawn object moves back to it's default location. For example, (using a line for simplicity's sake) if I have a line drawn at a y-value of 45.55, and I manually drag that line down to 43.50, with each update to the chart the line will reset itself back to 45.55. I'm guessing this is expected, but is there a way to stop it from happening? If I drag the object, I want it to stay where I dragged it, until I drag it someplace else.

              Comment


                #8
                Hello Radical,

                Yes, this is expected. If the code submits a new Draw statement, that it will move from any manually placed locations to the code placed once.

                You need to code some control so that it's not drawn again. You have one tag so the rectangle will always be redrawn each OnBarUpdate(). Unfortunately there is not a built in"OnManualMove" event you could listen for, so the control must be custom coded.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks, I will think about that and see what I come up with.

                  Comment


                    #10
                    Sorry for asking so many questions, but I was thinking I could just have the rectangle be drawn at a specific time of day (5:58:00 AM in this example), but this code doesn't work. The error I get is "Embedded statement cannot be a declaration or labeled statement."

                    PHP Code:
                    protected override void OnBarUpdate()
                            {
                                if (
                    ToTime(Time[0]) = 55800)
                                
                    IRectangle rectangle DrawRectangle("tag1"false10Low[10] - TickSize5High[5] + TickSizeColor.PaleGreenColor.PaleGreen2);
                            } 

                    Comment


                      #11
                      I'm glad to help. That seems like a good approach and that compile error is easy to resolve.

                      Change to this:
                      Code:
                      if (ToTime(Time[0]) == 55800)
                      {
                             IRectangle rectangle = DrawRectangle("tag1", false, 10, Low[10] - TickSize, 5, High[5] + TickSize, Color.PaleGreen, Color.PaleGreen, 2);
                      }
                      Ryan M.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks a lot, that solved the problem!

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by XXtrader, Yesterday, 11:30 PM
                        2 responses
                        11 views
                        0 likes
                        Last Post XXtrader  
                        Started by Waxavi, Today, 02:10 AM
                        0 responses
                        6 views
                        0 likes
                        Last Post Waxavi
                        by Waxavi
                         
                        Started by TradeForge, Today, 02:09 AM
                        0 responses
                        11 views
                        0 likes
                        Last Post TradeForge  
                        Started by Waxavi, Today, 02:00 AM
                        0 responses
                        2 views
                        0 likes
                        Last Post Waxavi
                        by Waxavi
                         
                        Started by elirion, Today, 01:36 AM
                        0 responses
                        7 views
                        0 likes
                        Last Post elirion
                        by elirion
                         
                        Working...
                        X