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

OrderFlow Volumetric Bars

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

    OrderFlow Volumetric Bars

    Hello,
    I am trying to work on a strategy using Values found in the OrderFlow Volume Profile Indicator.
    So far all got are null pointer exceptions...
    I tried to follow code examples from the documentation,:
    Code:
    [...]
    else if (State == State.Configure)
                {
                    AddVolumetric("mySelectedSeries", BarsPeriodType.Minute, 5, VolumetricDeltaType.BidAsk, 5);
                }
            }
    
            protected override void OnBarUpdate()
            {
                NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType barsType = Bars.BarsSeries.BarsType as
                NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType;
    
    
                Print("Bar index : " + CurrentBar.ToString());
                Print(barsType.Volumes[CurrentBar].GetMaximumVolume(null, out price) + "POC at: " + price);
    [...]

    Also I would like to be able to read out the highest and lowest Values of a Value Area of a specific bar. In my theory since it can be drawn on a chart, there must be a way to reach the numbers via code... am I missing something?

    #2
    Hello Foxmark,

    Welcome to the support forums.

    It looks like you just missed one of the comments in that sample for multi series:

    // This sample assumes the Volumetric series is the primary DataSeries on the chart, if you would want to add a Volumetric series to a

    // script, you could call AddVolumetric() in State.Configure and then for example use
    // NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[1].BarsType as
    // NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
    In this case you need to target the series you want to use.

    Code:
    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType barsType = [B]BarsArray[1].BarsType[/B] as
    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType;
    Keep in mind the sample shows CurrentBar being used, that won't be the CurrentBar for your primary series you would need to use CurrentBars[1] or wrap this code in a BarsInProgress condition:

    Code:
    if(BarsInProgress == 1)
    {
        //volumetric code here
    }

    Also I would like to be able to read out the highest and lowest Values of a Value Area of a specific bar. In my theory since it can be drawn on a chart, there must be a way to reach the numbers via code... am I missing something?
    Are you asking about a ValueArea indicator or is this something else you are doing on the chart?


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks for the quick answer.

      I see the error now and will try to change my code as soon as possible.
      As for the ValueArea, I attached an example of a chart I got, the chart uses 5 minute bars.
      The ValueArea of the middle bar got an upper line at 17,63 and a lower line at 17,55.

      The yellow bar should be readable with the above used "GetMaximumVolume(...)" method, but how can I read the blue lines via code?


      Comment


        #4
        Hello Foxmark,

        Thanks for your question.

        The volume for other price levels can be found using barsType.Volumes[CurrentBar].GetTotalVolumeForPrice(Close[0]) by specifying the price level of that bar you are looking to read volume on in place of Close[0].

        Code:
        NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType barsType = Bars.BarsSeries.BarsType as    
        NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType;
        
        if (barsType == null)
            return;
        
        Print("");
        Print("CurrentBar: " + CurrentBar);
        
        for (double price = Low[0]; price <= High[0]; price += TickSize)
        {
            Print(price + " " + barsType.Volumes[CurrentBar].GetTotalVolumeForPrice(price));
        }
        We look forward to assisting.
        JimNinjaTrader Customer Service

        Comment


          #5
          Hello, thanks again for an answer. Sadly this is not what I asked.
          The Order Flow Volume Profile indicator draws in the Value Area for a bar and marks the price for the upper and lower border of that area. I want to read out those price levels that are already drawn in the Chart.

          My current workaround is a manual add up of volumes around the POC price level, since that seems to be the only price level I can reach via code...

          Comment


            #6
            Hello Foxmark,

            Thank you for the reply.

            Currently the ValueArea upper and lower items you had noted are not specifically exposed as properties/methods in the volumetric options. If you have made a workaround that would likely be the best solution at this point.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by selu72, Today, 02:01 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_Zachary  
            Started by WHICKED, Today, 02:02 PM
            2 responses
            10 views
            0 likes
            Last Post WHICKED
            by WHICKED
             
            Started by f.saeidi, Today, 12:14 PM
            8 responses
            21 views
            0 likes
            Last Post f.saeidi  
            Started by Mikey_, 03-23-2024, 05:59 PM
            3 responses
            51 views
            0 likes
            Last Post Sam2515
            by Sam2515
             
            Started by Russ Moreland, Today, 12:54 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Erick  
            Working...
            X