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 cre8able, Today, 01:16 PM
        2 responses
        9 views
        0 likes
        Last Post cre8able  
        Started by chbruno, 04-24-2024, 04:10 PM
        3 responses
        48 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by samish18, Today, 01:01 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by WHICKED, Today, 12:56 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by WHICKED, Today, 12:45 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X