Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

1 bar volume

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

    1 bar volume

    Hello, I would like the indicator that comes standard in NT8 called VOL, instead of painting and calculating all the bars, to calculate and paint only 1 and in each tick, so that it does not load a lot of data, it is possible that someone can modify it ? Thank you very much in advance.

    public class VOL : Indicator
    {
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = Custom.Resource.NinjaScriptIndicatorDescriptionVOL ;
    Name = Custom.Resource.NinjaScriptIndicatorNameVOL;
    BarsRequiredToPlot = 0;
    Calculate = Calculate.OnEachTick;
    DrawOnPricePanel = false;
    IsSuspendedWhileInactive = true;

    AddPlot(new Stroke(Brushes.DodgerBlue, 2), PlotStyle.Bar, Custom.Resource.VOLVolume);
    AddLine(Brushes.DarkGray, 0, Custom.Resource.NinjaScriptIndicatorZeroLine);
    }
    else if (State == State.Historical)
    {
    if (Calculate == Calculate.OnPriceChange)
    {
    Draw.TextFixed(this, "NinjaScriptInfo", string.Format(Custom.Resource.NinjaScriptOnPriceCh angeError, Name), TextPosition.BottomRight);
    Log(string.Format(Custom.Resource.NinjaScriptOnPri ceChangeError, Name), LogLevel.Error);
    }
    }
    }

    protected override void OnBarUpdate()
    {
    Value[0] = Instrument.MasterInstrument.InstrumentType == InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume((long)Volume[0]) : Volume[0];
    }
    Attached Files

    #2
    Hello punkiy2111,

    Thanks for your post.

    Please note that have one volume bar for each tick would only be possible to plot if you applied the indicator to a single tick data series. Indicator plots are synchronized to the data series we apply the indicator against. So for a 1 tick data series, you would have "slots" for each tick. If you have the indicator applied to a 1 minute chart, you would have "slots" for each minute bar.

    Also to note, each bar does have volume associated with it, and this is what the indicator reads to display the Volume plot. There really is not any additional data loaded or additional processing. simply the volume of the bar is presented on the chart in a more visual way.

    Please let us know if you have any questions.

    Comment


      #3
      But is there a way that I can only see the last bar that is forming and not see the previous ones?

      Comment


        #4
        Hello punkiy2111,

        You can skip historical processing by adding the following to the top of the OnBarUpdate method:

        if (State == State.Historical) return;

        and this will skip execution historical bars and will only display plots that are calculated with realtime data.

        If you want to reset the previous plot values so only the current or last plots are displayed, this is possible by calling Values[PlotNumber].Reset(BarsAgo). However, we should note that this would not provide a performance benefit. You would actually be adding more work for the indicator to reset its previous plot values with each bar update.

        https://ninjatrader.com/support/help.../nt8/reset.htm

        We look forward to assisting.

        Comment


          #5
          Thanks, I'll try and tell you.

          Comment


            #6
            Thanks Jim, I just did what you told me and it works fine, write the last bar but the problem is that it starts to draw all the volume lines from here, so I would like to ask you ... can we make it write the last bar but the previous ones are primed in transparent color? So in this way you do not have to reset and worsen performance, could you please tell me how we could put it and in which section?
            Thank you very much for your help in advance.

            Comment


              #7
              Hello punkiy2111,

              Thanks for your reply.

              Add this line: PlotBrushes[0][1] = Brushes.Transparent;

              I would place it below the Value[0] = line.

              Please compile then remove the indicator from the chart and then reapply indicator.

              This will show one bar and one bar only.

              Comment


                #8
                Solved, wow, thank you very much, finally,
                You are very great the ninjatrader team !!!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                579 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                334 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                554 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                551 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X