Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plot on Current Bar Only

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

    Plot on Current Bar Only

    Hi All,

    I'm plotting up and down arrows to show the current bid and ask prices. I only want them to show on the current bar.

    They work fine except each arrow is shown on each bar across the chart. I don't want the chart cluttered. How do I limit the Plot arrows to the current bar only?

    I've tried using this code but it kills all arrows even on the current bar;

    PlotColors[0][1] = Color.Transparent

    Any Ideas?

    Thanks

    #2
    If you're using a Plot, there will be a value for each bar on the chart.

    If you just want to show on the current bar, you can use draw methods:

    Code:
    DrawText("bid", GetCurrentBid().ToString(), 0, High[0] + TickSize, Color.Blue);
    MatthewNinjaTrader Product Management

    Comment


      #3
      If you were using Arrows, you can also use the DrawArrow Up/Down methods:


      MatthewNinjaTrader Product Management

      Comment


        #4
        Mathew,

        Thank you for the response.

        Your examples use the "Draw" functionality. I'm using the Plot function and have not been able to figure out how to limit the plot to the current bar only. All of the triangles show up on each bar on the chart as a plot not a Draw Object.

        I have two Plots on the chart, one triangle for Bid and another for Ask. I've been trying this code with no luck;

        PlotColors[0][1] = Color.Transparent;
        PlotColors[1][1] = Color.Transparent;

        Do I need to do some kind of Reset function on a Dataseries object or something similar?

        Comment


          #5
          Originally posted by sheimdal View Post
          Mathew,

          Thank you for the response.

          Your examples use the "Draw" functionality. I'm using the Plot function and have not been able to figure out how to limit the plot to the current bar only. All of the triangles show up on each bar on the chart as a plot not a Draw Object.

          I have two Plots on the chart, one triangle for Bid and another for Ask. I've been trying this code with no luck;

          PlotColors[0][1] = Color.Transparent;
          PlotColors[1][1] = Color.Transparent;

          Do I need to do some kind of Reset function on a Dataseries object or something similar?
          If I'm now understanding correctly, what you're attempting should work. I put together a quick script and that seems to accomplish your goal using:

          Code:
                  protected override void OnBarUpdate()
                  {
          			
          			if(CurrentBar < 1)
          				return;
                      
          			PlotColors[0][1] = Color.Transparent;
          			PlotColors[1][1] = Color.Transparent;
          			
                      Plot0.Set(GetCurrentBid());
                      Plot1.Set(GetCurrentAsk());
                  }
          Please let me know if this is not what you're looking for.
          Attached Files
          MatthewNinjaTrader Product Management

          Comment


            #6
            It worked. I was using a different if statement using FirstTickOfBar. Using CurrentBar as you outlined fixed it.

            Thank you very much!

            Comment


              #7
              Originally posted by sheimdal View Post
              Mathew,

              Thank you for the response.

              Your examples use the "Draw" functionality. I'm using the Plot function and have not been able to figure out how to limit the plot to the current bar only. All of the triangles show up on each bar on the chart as a plot not a Draw Object.

              I have two Plots on the chart, one triangle for Bid and another for Ask. I've been trying this code with no luck;

              PlotColors[0][1] = Color.Transparent;
              PlotColors[1][1] = Color.Transparent;

              Do I need to do some kind of Reset function on a Dataseries object or something similar?
              I understand your query, but maybe you are forcing yourself to use a particular method simply because it is what you want to use, rather than because it is the most suitable for the purpose that you have described.

              For what you describe as your desired end result, it is much simpler to code, and more efficient to run, using a single reusable draw object (OK, in this case 2), than to use a DataSeries (which is what a Plot is).

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Barry Milan, Yesterday, 10:35 PM
              5 responses
              17 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by DanielSanMartin, Yesterday, 02:37 PM
              2 responses
              13 views
              0 likes
              Last Post DanielSanMartin  
              Started by DJ888, 04-16-2024, 06:09 PM
              4 responses
              13 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by terofs, Today, 04:18 PM
              0 responses
              12 views
              0 likes
              Last Post terofs
              by terofs
               
              Started by nandhumca, Today, 03:41 PM
              0 responses
              8 views
              0 likes
              Last Post nandhumca  
              Working...
              X