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

Only on current bar.

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

    Only on current bar.

    I've got an indicator that shows me how high or low a range bar would have to reach before it went to the next bar. I use a hash mark to show that limit. I would like that hash mark to only appear on the current bar. I don't need it to populate on past data.

    How do I make the indicator show on only the current bar?

    Thanks in advance!

    Brian.

    #2
    Hello Brian,

    This depends on how you are adding that hashmark to the screen.

    If you are using DrawText(), then reuse the drawing object tag and this will move the object instead of duplicating it.

    DrawText("textBox", "Displayed text", 0, High[0] + 5 * TickSize, Color.Blue);
    ^ this will draw only on the current bar

    DrawText("textBox" + CurrentBar, "Displayed text", 0, High[0] + 5 * TickSize, Color.Blue);
    ^ this will draw on all bars

    From the help guide:
    "Tag: A user defined unique id used to reference the draw object. For example, if you pass in a value of "myTag", each time this tag is used, the same draw object is modified. If unique tags are used each time, a new draw object will be created each time."
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      Here is my current code. This current version only prints a hash mark above each bar. I would like it to do both above and below but I've had problems with getting it to do both so I'm relegated to using two indicators right now. I am not using a DrawText function. I am just using a plot.

      Thanks!

      Code:
      protected override void Initialize()
              {
                  Add(new Plot(new Pen(Color.Black, 1), PlotStyle.Hash, "HighHash"));
                  Overlay				= true;
      			CalculateOnBarClose	= false;
      			
              }
      
      
              protected override void OnBarUpdate()
              {
      			if (CurrentBar<2) 
      				return;
      			
      			if (CurrentBar>=2)
      			{
      				HighHash.Set(Low[0] + ((barRange*.25) + .25));
      			}

      Comment


        #4
        Hello BReal,

        Once set, a plot will continue to have a value.

        To unset a value use DataSeries.Reset(int barsAgo);.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by proptradingshop, Today, 10:07 AM
        2 responses
        4 views
        0 likes
        Last Post proptradingshop  
        Started by sofortune, Today, 10:28 AM
        0 responses
        1 view
        0 likes
        Last Post sofortune  
        Started by marcus2300, Today, 10:21 AM
        1 response
        1 view
        0 likes
        Last Post marcus2300  
        Started by DawnTreader, 05-08-2024, 05:58 PM
        10 responses
        39 views
        0 likes
        Last Post DawnTreader  
        Started by gaz0001, Today, 10:09 AM
        0 responses
        2 views
        0 likes
        Last Post gaz0001
        by gaz0001
         
        Working...
        X