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

Questions on pulling orderflow data from additional data series

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

    Questions on pulling orderflow data from additional data series

    Hello, I have 2 questions. I have the following code:
    Code:
    else if (State == State.Configure)
                {
                    AddVolumetric(null, BarsPeriodType.Range, 26, VolumetricDeltaType.BidAsk, 1);
                }​
    and
    Code:
    #region Volumetric Setup
                if (Bars == null)
                      return;
                NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType barsType = Bars.BarsSeries.BarsType as    
                NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType;
                if (barsType == null)
                      return;
                #endregion
    
                i = 0;
                entropy_counter = 0;
                while (i <= Bars_Lookback)
                {
                    delta = barsType.Volumes[CurrentBar - i].BarDelta;
                    if ((Open[1][i] < Close[1][i]) && (delta < 0))
                    {
                        entropy_counter = entropy_counter + 1;
                    }
    
                    else if ((Open[1][i] > Close[1][i]) && (delta > 0))
                    {
                        entropy_counter = entropy_counter + 1;
                    }
                    i = i+1;
                }​
    First question: When I try to compile, it returns Cannot apply indexing with [] to an expression of type 'double' for both the "if statements". However, the "i" variable is declared as an integer, and stays an integer throughout the program. Maybe I am calling the additional data series incorrectly?

    Second question: in the line
    delta = barsType.Volumes[CurrentBar - i].BarDelta;
    , how would I pull the additional data series' bar delta instead of the primary chart data series' delta? The primary data series I am using for this chart is not a volumetric chart, however through some testing I found it is in fact pulling the bar delta for the primary data series instead of the additional volumetric data series.

    Thank you,

    Ryan Beckmann

    #2


    Open[1] will return one bar back the open price of the main data series from the chart which is a double and that is why you get the error. You need an s on the end to get the array of series:
    Opens[1][i]


    So you could try:

    while (i <= Bars_Lookback)
    {
    delta = barsType.Volumes[CurrentBar - i].BarDelta;
    if ((Opens[1][i] < Closes[1][i]) && (delta < 0))
    {
    entropy_counter = entropy_counter + 1;
    }

    else if ((Opens[1][i] > Closes[1][i]) && (delta > 0))
    {
    entropy_counter = entropy_counter + 1;
    }
    i = i+1;
    }​​​


    Hope that helps.​

    Comment


      #3
      Second question: in the line
      delta = barsType.Volumes[CurrentBar - i].BarDelta;
      , how would I pull the additional data series' bar delta instead of the primary chart data series' delta? The primary data series I am using for this chart is not a volumetric chart, however through some testing I found it is in fact pulling the bar delta for the primary data series instead of the additional volumetric data series.​



      NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[1].BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
      barDelta= barsType.Volumes[CurrentBar].BarDelta;

      Print(barDelta.ToString());

      that should give you the bar delta from the Volumetric bars.

      Hope that helps.​

      Comment


        #4
        Hello rbeckmann05,

        Thank you for your post.

        For your first question, eirwin1971 is providing good information on using Opens[] and Closes[].

        For your second question, to make sure you are pulling the barDelta value from your added Volumetric series, add a BarsInProgress check.

        BarsInProgress - https://ninjatrader.com/support/help...inprogress.htm

        BarsInProgress = 1 is your added data series.

        Also, please note that when adding multiple series, you will need to use BarsArray object with the corresponding index when casting the barsType.

        NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[1].BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;

        https://ninjatrader.com/support/help.../barsarray.htmm

        Please let me know if you have any other questions.
        Gaby V.NinjaTrader Customer Service

        Comment


          #5
          Thank you eirwin1971 and NinjaTrader_Gaby, was able to finish it up. Much appreciated to you especially eirwin, not a lot of people would take unpaid time out of their day to help out to that extent. Best of luck to you!

          Best regards,

          Ryan Beckmann

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by burtoninlondon, Today, 12:38 AM
          0 responses
          5 views
          0 likes
          Last Post burtoninlondon  
          Started by AaronKoRn, Yesterday, 09:49 PM
          0 responses
          14 views
          0 likes
          Last Post AaronKoRn  
          Started by carnitron, Yesterday, 08:42 PM
          0 responses
          11 views
          0 likes
          Last Post carnitron  
          Started by strategist007, Yesterday, 07:51 PM
          0 responses
          13 views
          0 likes
          Last Post strategist007  
          Started by StockTrader88, 03-06-2021, 08:58 AM
          44 responses
          3,983 views
          3 likes
          Last Post jhudas88  
          Working...
          X