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 gravdigaz6, Today, 11:40 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by MarianApalaghiei, Today, 10:49 PM
          3 responses
          10 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by XXtrader, Today, 11:30 PM
          0 responses
          4 views
          0 likes
          Last Post XXtrader  
          Started by love2code2trade, Yesterday, 01:45 PM
          4 responses
          28 views
          0 likes
          Last Post love2code2trade  
          Started by funk10101, Today, 09:43 PM
          0 responses
          9 views
          0 likes
          Last Post funk10101  
          Working...
          X