Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Keep drawings on the previous bars

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

    Keep drawings on the previous bars

    Hi,

    I am drawing a diamond from my indicator within the OnBarUpdate method on the most recent bar, however, once the bar closes and the next one starts the diamond moves to the new recent bar. I would like to keep my initial drawing as is and have a new drawing on the new bar.

    On a similar note, I want to be able to add my drawings to all the bars on the chart once I run my indicator. But, with the OnBarUpdate method, I can only target one specific bar.

    Code:
    protected override void OnBarUpdate()
            {   
                if (myCondition)
                {
                    Draw.Diamond(this, "tag1", true, -1, Low[0] - TickSize, Brushes.Magenta, true);
                } 
            }​

    #2
    Hello pouya-p,

    To have unique objects you need to use unique tags. You can append CurrentBar to the tag to make them unique:

    "tag1" + CurrentBar

    That will allow the objects to remain on the bars that have been processed.

    Comment


      #3
      Hi Jesse,

      Thanks, this was really helpful.

      Regards,
      Pouya

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      21 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      50 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Working...
      X