Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

draw objects display

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

    draw objects display

    Hallo,

    I need to add some script into the existing one to change the settings of the draw objects display.
    They are displaying "Calculate on bar close - false" right in the moment of creation (the conditions are executed) - it's ok.
    But I also need to add the script to remove the drawing object right in the moment of termination (in case the conditions are no longer executed) before the price bar will be closed.

    Thank you for your help,
    Richard
    Attached Files

    #2
    Hello,

    Thank you for your forum post.

    In this case you would need to run the Strategy in Calculate on Bar Close = False.

    Then move all your COBC = True logic in your indicator code to if(FirstTickOfBar)
    {
    //You OnBarUpdate code here, this works in COBC = True mode.
    }


    Then outside of this you will add your code to delete the drawing objects if the conditions are no longer true, this will execute on every tick allowing you to remove the drawing object if the condition was no longer true.

    Another method to do this if you dont want the objects deleted at the first sign of the conditions no longer being true, would be to check this on the creation of the next bar weather or not the previous bars conditions where true and remove the drawing objects if they are not true. Best way to do this would be with a boolSeries.



    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      ... I have thought about ang got solution. Is it correct?
      thanks for advice.

      protected override void Initialize()
      {
      CalculateOnBarClose = false;
      }
      protected override void OnBarUpdate()
      {
      // Condition set 1
      if (//some conditions)
      {
      DrawTriangleUp("My triangle up" + CurrentBar, false, 0, Low[0] + -10 * TickSize, Color.Lime);
      DrawText("My text up" + CurrentBar, "0/v", 0, Low[0] + -15 * TickSize, Color.DimGray);
      }
      // Condition set 2
      else if (//some conditions)
      {
      DrawTriangleDown("My triangle down" + CurrentBar, false, 0, High[0] + 10 * TickSize, Color.Crimson);
      DrawText("My text down" + CurrentBar, "0/v", 0, High[0] + 15 * TickSize, Color.DimGray);
      }
      else
      {
      RemoveDrawObject("My triangle up" + CurrentBar);
      RemoveDrawObject("My text up" + CurrentBar);
      RemoveDrawObject("My triangle down" + CurrentBar);
      RemoveDrawObject("My text down" + CurrentBar);
      }
      }
      Attached Files

      Comment


        #4
        Hello,

        Does it run as you expect live?

        There are always 10 different ways to do things in coding Looks like it should work though.

        Let me know if I can be of further assistance.
        BrettNinjaTrader Product Management

        Comment


          #5
          Hello,

          yes it runs as I expected

          Comment


            #6
            Excellent, Great job!
            BrettNinjaTrader Product Management

            Comment


              #7
              This is the final output, just for accuracy.

              Code:
              protected override void Initialize()
                      {
                          CalculateOnBarClose = false;
                      }
              protected override void OnBarUpdate()
                      {
                          // Condition set 1
                          if (//some conditions)
                          {
                              DrawTriangleUp("My triangle 0v up" + CurrentBar, false, 0, Low[0] + -10 * TickSize, Color.Lime);
                              DrawText("My text 0v up" + CurrentBar, "0/v", 0, Low[0] + -15 * TickSize, Color.DimGray);
                          }
              			else
              			{
              				RemoveDrawObject("My triangle 0v up" + CurrentBar);
              				RemoveDrawObject("My text 0v up" + CurrentBar);
              			}
              
                          // Condition set 2
                          if (//some conditions)
                          {
                              DrawTriangleDown("My triangle 0v down" + CurrentBar, false, 0, High[0] + 10 * TickSize, Color.Crimson);
                              DrawText("My text 0v down" + CurrentBar, "0/v", 0, High[0] + 15 * TickSize, Color.DimGray);
                          }
              			else
              			{
              				RemoveDrawObject("My triangle 0v down" + CurrentBar);
              				RemoveDrawObject("My text 0v down" + CurrentBar);
              			}
                      }

              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