Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Remove DrawObjects on OrderFill

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

    Remove DrawObjects on OrderFill

    Hi, I have a strategy using bracket orders after my entry was filled.
    I have my strategy draw lines at the target and stop prices on the chart.
    I have the lines drawn in the on order update method.
    My question is how do I remove the lines from the chart, when either one of the bracket orders is filled. Meaning if the orders are filled or cancelled the lines on the chart should be removed too.
    Should work like if you are using the charttrader, if there is an existing order, display line at price, if order is filled, canceled or updated, remove or update the lines.

    Regards

    #2
    Hello,

    Thank you for the question.

    If these lines are only drawn when you are in a position and need to be removed when you are out of the position you can try to call RemoveDrawObjects(); this removes any script added objects.


    otherwise if this does not work as expected you could define a variable that you will set as an ILine object, this will allow you to modify or update the line and also remove it.

    Code:
    private ILine line1 = null;
    protected override void OnBarUpdate()
    {
         //set the variable to a line that we create
         line1 = DrawLine("tag", true, 0, Close[0], 10, Close[0], Color.Red, DashStyle.Solid, 1);
        
         //If you want to then update the line
         line1.StartY = Close[0];
         line1.EndY = Close[0];
    
         //when you want to remove the object
         RemoveDrawObject(line1);
         line1 = null;
    }
    Please let me know if I may be of additional assistance.

    Comment


      #3
      Thanks,

      Marketposition.Flat works in the Order Update method.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      558 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      545 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X