Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      Thanks, this was really helpful.

      Regards,
      Pouya

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by halgo_boulder, 04-20-2024, 08:44 AM
      2 responses
      21 views
      0 likes
      Last Post halgo_boulder  
      Started by mishhh, 05-25-2010, 08:54 AM
      19 responses
      6,189 views
      0 likes
      Last Post rene69851  
      Started by gwenael, Today, 09:29 AM
      0 responses
      5 views
      0 likes
      Last Post gwenael
      by gwenael
       
      Started by Karado58, 11-26-2012, 02:57 PM
      8 responses
      14,830 views
      0 likes
      Last Post Option Whisperer  
      Started by Option Whisperer, Today, 09:05 AM
      0 responses
      2 views
      0 likes
      Last Post Option Whisperer  
      Working...
      X