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 lightsun47, Today, 03:51 PM
              0 responses
              5 views
              0 likes
              Last Post lightsun47  
              Started by 00nevest, Today, 02:27 PM
              1 response
              8 views
              0 likes
              Last Post 00nevest  
              Started by futtrader, 04-21-2024, 01:50 AM
              4 responses
              45 views
              0 likes
              Last Post futtrader  
              Started by Option Whisperer, Today, 09:55 AM
              1 response
              14 views
              0 likes
              Last Post bltdavid  
              Started by port119, Today, 02:43 PM
              0 responses
              9 views
              0 likes
              Last Post port119
              by port119
               
              Working...
              X