Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Creating a DrawingTool that follows the price and is extended

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

    Creating a DrawingTool that follows the price and is extended

    I've created an indicator where I'm using RegionHorizontalY, but the thing is if I draw this it's annoying the left side because I just need the right side, so I'm looking for alternatives, is there any drawing tool that I can be expanding meanwhile the price is moving?

    Something like this
    Click image for larger version  Name:	image.png Views:	0 Size:	652 Bytes ID:	1302102

    This red "rectangle" that have a start point with heigh and bottom that when the High[0] of the candle touches it it decreases the size.
    Also for the one that have been not touched for instance
    Click image for larger version  Name:	image.png Views:	0 Size:	2.1 KB ID:	1302103

    But I don't want it to stretch I want to be like the start one getting smaller until dissapear.

    Do I have to create a new drawing tool or can I do it with any of the ones of Ninja Trader 8?

    Note:

    I have topPrice and botPrice set, and depending I'm making this RegionHorizontalY smaller until dissapear I want the same but without the left part and everytime the price closes a bar it renders the line :

    It could be also like this
    Click image for larger version  Name:	image.png Views:	0 Size:	1.0 KB ID:	1302104
    but I'd like to make the component smaller everytime is touched by a High[0] or Low[0], any guide or idea how to do it? Is there any free drawing tools that does this?

    I've thought another way but maybe is not the correct, it doesn't work though because maybe I'm presenting it wrongly, since I have a Dictionary of my rectangles and I need to expand them I thought that it could be a good idea to store as a key the tag of the rectangle and then the start Position, but I've tried with CurrentBar and it prints wrong, I want from the moment I draw the rectangle draw it there, not at the start of the Chart, how can I get the position of the bar or whatever?

    Thanks in advantage.
    Last edited by cmtjoancolmenero; 05-03-2024, 03:47 AM.

    #2
    Hello cmtjoancolmenero,

    Creating a new drawing tool would not be a good use case for what you described, drawing tools work based on mouse click locations where anchors are placed. Anchors do not move once they are placed so the object would not move with the price. An indicator could make drawings that move with the price because it has a OnBarUpdate event where new prices could be used to draw on new bars. This would be very similar to your other post about the reducing rectangle, you would need to update a drawing object for each bar if you wanted to move it forward in time as time progresses. If the existing drawing object do not work for the use case you wanted you could stop using a drawing object and use OnRender from the indicator which would allow you to custom render anything you wanted similar to how drawing tools render.





    Comment


      #3
      Hello Jesse,

      The thing is that I already have all the logic working, the only thing missing is that I do not want to use regionHighlightY anymore and just use a Rectangle or whatever as my images attached, the only thing I need to know is how can I draw a Rectangle with start the candle I'm drawing it, and the end of the rectangle be the end of the chart.

      The questios is pretty straightforward IMHO, I have a condition to print only 1 rectangle per day, so the first moment I draw a rectangle I already have the top and bot I want this rectangle needs to be, the thing is I don't know how to place it in the position where I'm checking it (it's when the first candle of the day), and the long of the rectangle should be the end of the chart as if you add 0 it goes to the left I want this rectangle be to the right.

      Comment


        #4
        Hello cmtjoancolmenero,

        As this question relates to your other post I ask that we continue the conversation there so we are not double posting about the same issue.

        To place a object for the whole session you would use the bars ago Bars.BarsSinceNewTradingDay as the start bars ago and 0 for the end bars ago.

        Comment


          #5
          Hello Jesse,

          Yes, now using this :
          Draw.Rectangle(this, tag, 0, topPrice, CurrentBar - startBars[tag], bottomPrice, Brushes.Red);

          It does work, the thing is kinda laggy because I'm doing a forloop to get all drawingObjects to get mines and then update on each onBarClose() and I don't know if it's ineficcient this or is there any other way it should do this logic, because I need to update the size of the rectangle onEachCloseBar so I have to loop through all the bars I've drawn and update the size, any idea on how to do it faster and efficient?

          Comment


            #6
            Hello cmtjoancolmenero,

            Please repost this question in your existing forum post so we can maintain that information in one area, we always ask that you only create 1 post per topic so we are not spreading resources out between many posts.

            Hello I'm developing an indicator, from now I've drawn a RegionHIghLightY as : ``` protected override void OnBarUpdate() { if (CurrentBar == 0) return; // Define the coordinates for the rectangle double top = SomeCalculationTop; double bot= SomeCalculationBot; // Draw the rectangle Draw.RegionHighlightY(this,


            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            602 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            347 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            560 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            559 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X