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 TheWhiteDragon, 01-21-2019, 12:44 PM
          4 responses
          541 views
          0 likes
          Last Post PaulMohn  
          Started by GLFX005, Today, 03:23 AM
          0 responses
          2 views
          0 likes
          Last Post GLFX005
          by GLFX005
           
          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
          7 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Started by TradeForge, Today, 02:09 AM
          0 responses
          14 views
          0 likes
          Last Post TradeForge  
          Working...
          X