Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

RemoveDrawObject

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

    RemoveDrawObject

    My indicator draws a horizontal line ("DrawLine") when two conditions are fulfilled. The second part is that when either of these two conditions reverses within the same bar it is supposed to "RemoveDrawObject" i.e. remove the line. It does not do that. Only when I push F5 to refresh the chart does the line disappear.


    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] < BarsRequired)
    return;

    if(BarsInProgress != 0) return;

    if (Rising (LinReg(BarsArray[0],4))
    && Rising (LinReg(BarsArray[0],9)))

    {
    DrawLine("SLup", false, 0, Low[0], 1, Low[0], upColor, DashStyle.Solid, 2);
    }

    if
    (
    (Falling(LinReg(BarsArray[0],4)))
    ||
    (Falling(LinReg(BarsArray[0],9)))
    )

    {
    RemoveDrawObject("SLup");
    }

    Do you have any advice?

    sandman

    #2
    Hello sandman,

    Thank you for writing in.

    RemoveDrawObject() will immediately remove the draw object when called.

    I do see that you have this within a condition. Have you added print statements to ensure that the condition is true?

    Additionally, as you want to check for these conditions intrabar, is your CalculateOnBarClose property set to false?

    As a test, are you able to see the diamond removed in the sample code below once a new bar closes?
    Code:
    protected override void Initialize()
    {
         CalculateOnBarClose = false;
    }
    
    private bool removed = false;
    
    protected override void OnBarUpdate()
    {
         if (Historical)
              return;
    
         if (!removed)
              DrawDiamond("diamond", true, 0, Close[0], Color.Blue);
    
         if (FirstTickOfBar)
         {
              RemoveDrawObject("diamond");
              removed = true;
         }
    }
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Resolved. Thank you Zachary.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by samir, Today, 07:00 PM
      0 responses
      9 views
      0 likes
      Last Post samir
      by samir
       
      Started by travisloneker, Today, 06:52 PM
      0 responses
      7 views
      0 likes
      Last Post travisloneker  
      Started by InfraredBusa, Today, 05:50 PM
      0 responses
      3 views
      0 likes
      Last Post InfraredBusa  
      Started by White Fork, Today, 04:56 PM
      1 response
      8 views
      0 likes
      Last Post White Fork  
      Started by steveyinyang, Today, 02:48 PM
      3 responses
      22 views
      0 likes
      Last Post steveyinyang  
      Working...
      X