Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Volumetric Bars as Secondary Data Series

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

    #16
    Hello f.saeidi,

    Thanks for your notes.

    Please review the help guide documentation linked in post # 14 and try making the modifications yourself first.

    You would need to add a CurrentBars check at the top of your OnBarUpdate() logic for the primary series and secondary series the script is using.

    For example:

    Code:
    if (CurrentBars[0] < 10 || CurrentBars[1] < 10)
            return;​
    You would need to add a condition to the script that checks if Bars == null as seen in the Order Flow Volumetric help guide sample code. This would be placed after the CurrentBars check.

    For example:

    Code:
    if (Bars == null)
              return;​
    And, after you are defining barsType in your script and before you call Draw.TextFixed() you would need to check if barsType == null. An example of this can be seen in the Order Flow Volumetric Bars help guide sample code.

    For example:

    Code:
    if (barsType == null)
              return;​
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #17
      i add your tips and its work well now, but my friend please look at below code that mentioned in nt8 user manual:
      if (CurrentBars[0] < 10 || CurrentBars[1] < 10)

      this code not work well with || (OR)
      instead i apply &&(AND) and its work well.


      another issue is about below code:

      AddVolumetric("NQ 06-24", BarsPeriodType.Minute, 1, VolumetricDeltaType.BidAsk, 0);

      sometimes change nazdaq instrument name.
      can i use "NULL" instead "NQ 06-24"?
      i applied NULL and didnt appear anything in screen.
      i need script work with all instrument names and dont change instrument name in script.
      what is your advice?
      thnx..

      Comment


        #18
        how can i use candle 1 and candle 2 and candle 3 delta bar information for compare?
        for example
        if ( candle 0 (delta bar ) > candle 1 (delta bar) )
        write on screen positive.
        i need to call 6 candle delta bar information.

        Comment


          #19
          Hello f.saeidi,

          Thanks for your notes.

          You could use an && {AND) operator instead of an || (OR) operator in your CurrentBars condition if you find this works better for you.

          You can pass in a null argument for the instrument name when calling AddVolumetric().

          For example:

          AddVolumetric(null, BarsPeriodType.Minute, 1, VolumetricDeltaType.BidAsk, 1);

          To access previous delta values you would need to create a custom Series object in your script, save the BarDelta value to the custom Series, and then access the custom Series using a barsAgo value.

          Passing a barsAgo value of 0 in for the custom Series would get the current bar value of that Series. Passing a barsAgo value of 1 in for the custom Series would get the previous bar value of that Series. Passing in a barsAgo value of 2 in for the custom Series would get the value 2 bars from the current bar, and so on.

          See the help guide documentation below for more information.

          Series<T>: https://ninjatrader.com/support/help...t8/seriest.htm

          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

          Comment


            #20
            Dear BrandonH
            thnx for your notes.

            what about multi time frame?
            for example
            if ( ( current value candle 0 (weekly) > open candle 0 (weekly) ) & ( ( current value candle 0 (daily) > open candle 0 (daily) ) &
            ( ( current value candle 0 (4 hour) > open candle 0 (4 hour) ) & ( ( current value candle 0 (1 hour) > open candle 0 (hour) ) )
            {
            give me signal
            }

            how can i read multi time frame candle status?
            and imagine i only opened 1 min time frame and want to read multi time frame status on in 1 minute chart...
            Thnx.


            Comment


              #21
              Hello f.saeidi,

              The price series for each added series are available in the Closes, Opens, Lows, Highs, Times, and Volumes collections.




              Closes[barsInProgressIndex][barsAgoIndex]

              For example if I wanted the close of the third series (second series added with AddDataSeries()) I would use: Closes[2][0].


              With using && (AND) or || (OR) this would depend if you were calling a return or execution the logic in the block.

              if (CurrentBars[0] > 0 && CurrentBars[1] > 0)
              {
              // code only within this block is only executed if both series have 1 bar
              }

              if (CurrentBars[0] < 1 || CurrentBars[1] < 1)
              return;
              // code below this point is only executed if both series have 1 bar
              Chelsea B.NinjaTrader Customer Service

              Comment


                #22
                i guess your above condition is correct only for close candles.
                can i use GetCurrentBid()​ ?
                i need live candle bid and ask price for multi time frame.

                Comment


                  #23
                  Hello f.saeidi,

                  This would also apply to currently building bars with Calculate.OnPriceChange/.OnEachTick.

                  With GetCurrentBid() you would need to call this during the BarsInProgress of the desired series.

                  if (BarsInProgress == 2)
                  Print(GetCurrentBid());
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #24
                    i add some script.here i need to print multi time frame bid price on screen:


                    AddDataSeries(null, BarsPeriodType.Minute, 1);
                    AddDataSeries(null, BarsPeriodType.Minute, 5);
                    AddDataSeries(null, BarsPeriodType.Minute, 15);
                    AddDataSeries(null, BarsPeriodType.Minute, 30);



                    }
                    }

                    protected override void OnBarUpdate()
                    {

                    double currentBid_m1=GetCurrentBid();
                    double currentBid_m5=GetCurrentBid();

                    if ((BarsInProgress == 1 ))


                    Draw.TextFixed(this, "", "currentBid_m1:"+GetCurrentBid(0),
                    TextPosition.TopLeft);




                    if ((BarsInProgress == 2 ))



                    Draw.TextFixed(this, "", "currentBid_m5:"+GetCurrentBid(0),
                    TextPosition.TopLeft);​



                    above script only show m5 bid price and dont show m1 bid price.

                    can i add m5,m15,m30 Bid price on Draw.Text Fixed??
                    how?
                    Last edited by f.saeidi; 03-23-2024, 08:43 AM.

                    Comment


                      #25
                      I want to see multi time frame chart information in only 1 minute chart.

                      Comment


                        #26
                        Hello f.saeidi,

                        Thanks for your notes.

                        To clarify, you only want to draw the current bid price for the added secondary 1-Minute series on the chart. Is that correct?

                        You could create a class-level double variable called something like oneMinuteBid, check if BarsInProgress == 1, and assign the GetCurrentBid() value to the oneMinuteBid variable.

                        Then call Draw.TextFixed() and pass the oneMinuteBid variable in for the string Text argument of the Draw method.

                        If you want to draw text for both added series when the added 1-Minute series processes, you would need to create another class-level variable called something like fiveMinuteBid, check if BarsInProgress == 2, and assign the GetCurrentBid() value to the fiveMinuteBid variable.

                        You could then call Draw.TextFixed() when BarsInProgress == 1 and pass the fiveMinuteBid variable in for the string Text argument when calling the Draw method to draw that value on the chart when BarseInProgress 1 processes.

                        See the help guide documentation below for more information.

                        BarsInProgress: https://ninjatrader.com/support/help...inprogress.htm
                        GetCurrentBid(): https://ninjatrader.com/support/help...currentbid.htm
                        Draw.TextFixed(): https://ninjatrader.com/support/help..._textfixed.htm
                        Working with Multi-TimeFrame/Multi-Instrument NinjaScripts: https://ninjatrader.com/support/help...nstruments.htm
                        Last edited by NinjaTrader_BrandonH; 03-25-2024, 08:40 AM.
                        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                        Comment


                          #27
                          For clarify I want to see open close high low for daily 4h 2h 30h.
                          You know all above information seen in 1 minute chart in left side.
                          How can I gather above information in multi chart??
                          Main problem is when I use drawfixed for example after bars in progress==1
                          I can't apply another time frame information.
                          May I see your desire script for my problem.
                          Thnx

                          Comment


                            #28
                            Hello f.saeidi,

                            Thanks for your notes.

                            Draw.TextFixed() will draw text to a specific corner of the chart window, such as the bottom left corner of a chart or the bottom right corner of a chart.

                            To draw the values from the added 1-Minute series on the chart, you could create a class-level variable for each value you want to access, check if BarsInProgress == 1, and assign the values to those variables inside the BarsInProgress == 1 condition. Then, you could call Draw.TextFixed() with the BarsInProgress == 1 condition to draw those values on the chart.

                            Attached is a simple example script demonstrating this.

                            If you want to draw text on the chart for other added series information, you would need to make sure you set the Draw.TextFixed() tag argument to a unique name and draw the text in a different location so the Draw.TextFixed methods do not overlap on the chart.

                            From the Draw.TextFixed() 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.​"


                            For example, you could call Draw.TextFixed() in BarsInProgress 1 with a tag name of "OneMinText" and a location of TextPosition.BottomRight. You could then call Draw.TextFixed() in BarsInProgress 2 with a tag name of "FiveMinText" and a location of TextPosition.BottomLeft.

                            Please review the help guide documentation linked on post # 26 for more information.​
                            Attached Files
                            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                            Comment


                              #29
                              please look at below script:

                              region Using declarations
                              using System;
                              using System.Collections.Generic;
                              using System.ComponentModel;
                              using System.ComponentModel.DataAnnotations;
                              using System.Linq;
                              using System.Text;
                              using System.Threading.Tasks;
                              using System.Windows;
                              using System.Windows.Input;
                              using System.Windows.Media;
                              using System.Xml.Serialization;
                              using NinjaTrader.Cbi;
                              using NinjaTrader.Gui;
                              using NinjaTrader.Gui.Chart;
                              using NinjaTrader.Gui.SuperDom;
                              using NinjaTrader.Gui.Tools;
                              using NinjaTrader.Data;
                              using NinjaTrader.NinjaScript;
                              using NinjaTrader.Core.FloatingPoint;
                              using NinjaTrader.NinjaScript.DrawingTools;
                              #endregion

                              //This namespace holds Indicators in this folder and is required. Do not change it.
                              namespace NinjaTrader.NinjaScript.Indicators
                              {
                              public class MultiTime2 : Indicator
                              {
                              private double oneMinOpen;
                              private double oneMinClose;
                              private double oneMinBid;


                              private double fiveMinOpen;
                              private double fiveMinClose;
                              private double fiveMinBid;

                              private double fifteenMinOpen;
                              private double fifteenMinClose;
                              private double fifteenMinBid;

                              protected override void OnStateChange()
                              {
                              if (State == State.SetDefaults)
                              {
                              Description = @"Enter the description for your new custom Indicator here.";
                              Name = "MultiTime2";
                              Calculate = Calculate.OnBarClose;
                              IsOverlay = true;
                              DisplayInDataBox = true;
                              DrawOnPricePanel = true;
                              DrawHorizontalGridLines = true;
                              DrawVerticalGridLines = true;
                              PaintPriceMarkers = true;
                              ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                              //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                              //See Help Guide for additional information.
                              IsSuspendedWhileInactive = true;
                              }
                              else if (State == State.Configure)
                              {
                              AddDataSeries(Data.BarsPeriodType.Minute, 1);
                              AddDataSeries(Data.BarsPeriodType.Minute, 5);
                              AddDataSeries(Data.BarsPeriodType.Minute, 15);




                              }
                              }

                              protected override void OnBarUpdate()
                              {
                              if (CurrentBars[0] < 10 || CurrentBars[1] < 10)
                              return;

                              if (BarsInProgress == 1)
                              {
                              oneMinOpen = Open[0];
                              oneMinClose = Close[0];
                              oneMinBid = GetCurrentBid();

                              Draw.TextFixed(this, "DrawTextFixedBIP1", "OneMinOpen: "
                              + oneMinOpen + " OneMinClose: " + oneMinClose + " OneMinBid: "
                              + oneMinBid + "fiveMinOpen:"+fiveMinOpen+" fiveMinClose: "
                              + fiveMinClose+" fiveMinBid: "
                              + fiveMinBid + "fifteenMinOpen:"+fifteenMinOpen+" fifteenMinClose: "
                              + fifteenMinClose+" fifteenMinBid: "
                              + fifteenMinBid , TextPosition.TopLeft);


                              if (BarsInProgress == 2)
                              {
                              fiveMinOpen = Open[0];
                              fiveMinClose = Close[0];
                              fiveMinBid = GetCurrentBid();


                              }

                              if (BarsInProgress == 3)
                              {
                              fifteenMinOpen = Open[0];
                              fifteenMinClose = Close[0];
                              fifteenMinBid = GetCurrentBid();


                              }







                              }


                              }
                              }
                              }

                              region NinjaScript generated code. Neither change nor remove.

                              namespace NinjaTrader.NinjaScript.Indicators
                              {
                              public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
                              {
                              private MultiTime2[] cacheMultiTime2;
                              public MultiTime2 MultiTime2()
                              {
                              return MultiTime2(Input);
                              }

                              public MultiTime2 MultiTime2(ISeries<double> input)
                              {
                              if (cacheMultiTime2 != null)
                              for (int idx = 0; idx < cacheMultiTime2.Length; idx++)
                              if (cacheMultiTime2[idx] != null && cacheMultiTime2[idx].EqualsInput(input))
                              return cacheMultiTime2[idx];
                              return CacheIndicator<MultiTime2>(new MultiTime2(), input, ref cacheMultiTime2);
                              }
                              }
                              }

                              namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
                              {
                              public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
                              {
                              public Indicators.MultiTime2 MultiTime2()
                              {
                              return indicator.MultiTime2(Input);
                              }

                              public Indicators.MultiTime2 MultiTime2(ISeries<double> input )
                              {
                              return indicator.MultiTime2(input);
                              }
                              }
                              }

                              namespace NinjaTrader.NinjaScript.Strategies
                              {
                              public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
                              {
                              public Indicators.MultiTime2 MultiTime2()
                              {
                              return indicator.MultiTime2(Input);
                              }

                              public Indicators.MultiTime2 MultiTime2(ISeries<double> input )
                              {
                              return indicator.MultiTime2(input);
                              }
                              }
                              }

                              #endregion

                              Attached Files

                              Comment


                                #30
                                i made some change in above script but main problem is i cant get any data for 5 minute (open-close-current bid) and
                                15 minute (open-close-current bid) and only seen 0 value in chart.
                                may i see your desire script code?

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                608 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                355 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                105 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                560 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                561 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X