• 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

Multiple Draw.Rectangles - getting correct tag

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

    Multiple Draw.Rectangles - getting correct tag

    Hello,

    I have written an indicator that allows for user (mouse) drawn multiple rectangles on a chart. I have done this using the Rectangle myRec approach and placed code in OnRender. Each rectangle draw has an incremental tag.

    On the chart when one of the rectangles is selected myRec.IsSelected is returned true, however I have been unable to get the correlating myRec.Tag. Any suggestions on this can be achieved?

    Alternatively is there a way to index myRec[x] so each instance is unique?

    Thank you.

    #2
    Hello,

    Can you please share the code you are using to assign and identify myRec? I should be able to provide insight into how to obtain the tag properly once I see your starting point.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      Hi Dave,

      Thank you for your reply. In summary my approach with myRec is;

      To Assign, under public class > Rectangle myRec

      From Toolbar button when pressed > Cnt++ which is used in several ways and as Tag for myRec

      In OnRender


      myRec = Draw.Rectangle(this, Cnt.ToString(), etc

      then a loop using Cnt to cycle through each myRec Tag looking for myRec.IsSelected.

      My problem seems to be IsSelected belongs to myRec and not the Tag so when Rectangle is selected on the chart, all Tag instances of myRec are true.

      I really need to use myRec+Cnt, myRec+Cnt etc for each Rectangle drawn but cant work out how to do this.

      I am using this approach as it is easier (for my level of coding skill) to select, modify, delete the Rectangles.

      Hope you can help - thank you.

      Comment


        #4
        Thank you for elaborating. I've set up a small sample that appears to accomplish what you are looking for using two NS-drawn objects with unique tags (see attached). Since my script is working with manually assigned unique tags, perhaps the issue in your script lies with the Cnt variable not being incremented as you expect.

        Hopefully the attached sample will point you in the right direction. If not, if you could share an actual script that is producing the issue for you, I'll be happy to look deeper.
        Attached Files
        Dave I.NinjaTrader Product Management

        Comment


          #5
          H Dave,

          That worked - excellent.

          Thank you very much.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Grantx, Today, 08:22 AM
          0 responses
          2 views
          0 likes
          Last Post Grantx
          by Grantx
           
          Started by Swing123, Today, 08:21 AM
          0 responses
          3 views
          0 likes
          Last Post Swing123  
          Started by lunardiplomacy, Today, 07:57 AM
          0 responses
          3 views
          0 likes
          Last Post lunardiplomacy  
          Started by Tagliareni, Yesterday, 08:10 PM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_PaulH  
          Started by SDaCosta30, Today, 04:19 AM
          2 responses
          11 views
          0 likes
          Last Post SDaCosta30  
          Working...
          X