Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AddVolumetric() to Strategy

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

    AddVolumetric() to Strategy

    I am trying to GetMaximumVolume on Range bars for my strategy. I can AddVolumetric and compile but when I enable the strategy it throws an 'unhandled exception' error. I found note 6 from the AddVolumetric() help page . . . .

    "A Tick Replay indicator or strategy CANNOT use a MarketDataType.Ask or MarketDataType.Bid series. Please see Developing for Tick Replay for more information."

    I think this is telling me it is not possible to AddVolumetric to a strategy. Is that true? I looked at the "Strategy Builder". There is no option to AddVolumetric there either. The absence of this option in the builder seems to confirm it is not possible.

    Question: how can I get this information into my strategy?

    p.s. I'm thinking to create an indicator with AddVolumetric that produces a bool when my trade condition is true. I can read the indicator bool to trigger a trade in the strategy. But . . . this is very inefficient.

    #2
    Hello,

    Below is a link to the help guide on using the Volumetric bars once they have been added to the script.


    Are you looking for:
    Print("Max seen delta (bar): " + barsType.Volumes[CurrentBar].MaxSeenDelta);


    With the message:
    "A Tick Replay indicator or strategy CANNOT use a MarketDataType.Ask or MarketDataType.Bid series. Please see Developing for Tick Replay for more information."

    Are you adding series with AddDataSeries() that use MarketDataType.Ask or MarketDataType.Bid and actually getting this error?
    If so, that unfortunately will not be possible when using AddVolumetric().


    This does not mean you cannot add AddVolumetric() to an unlocked strategy. This just means you can't add this and then add series with MarketDataType.Ask or MarketDataType.Bid as well. You can only add AddVolumetric() and you can add series with AddDataSeries() that use MarketDataType.Last.

    The Strategy Builder is limited to very simple scripts and cannot use Order Flow bar types or indicators. Using Order Flow in NinjaScript is advanced and requires unlocking the script and coding by hand.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you @NinjaTrader_ChelseaB. This is helpful.

      I'm using straight up AddVolumetric() only. I am trying to access "Maximum Combined" using " barsType.Volumes[CurrentBar].GetMaximumVolume(null, out price)". I am not trying to also AddDataSeries() in addition or access MarketDataType.Ask or MarketDataType.Bid.

      I guess the error is coming from some other place in my code. I'll keep looking.

      Comment


        #4
        Hello kafabla,

        Are you confirming this script is causing the error 'A Tick Replay indicator or strategy CANNOT use a MarketDataType.Ask or MarketDataType.Bid series. Please see Developing for Tick Replay for more information.', on the Log tab of the Control Center, when this specific script is enabled?

        May we see the code in OnStartUp()? (All of the code in OnStartUp())
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          @NinjaTrader_ChelseaB. No, I am not confirming any problems with NinjaScript. I found the problem. It turned out to be oversight on my part. I was not referencing the correct BarsInProgress.

          All is well. Again, thank you. I appreciate your quick and thorough response.

          Comment


            #6
            kafabla hello sir even i was tried to developw my own strategy using range bar volumatric bar

            i was finding difficulty to get poc value and store to any double variable and use it for condition
            would you please help me with the code

            that how can i fetch previous candle POC and current candle POC and store to any variable

            Comment


              #7
              Hello siddhugaddi,

              Unfortunately, the Volumetric bars do not have a POC value available.

              Below is a link to the help guide.


              But may be something that can be custom calculated from the GetMaximumVolume() and GetTotalVolumeForPrice (). Below is a link to a forum post that discusses.


              To save a value to a double variable:
              double myVariable = barsType.Volumes[CurrentBar].GetTotalVolumeForPrice(Close[0])​;
              Chelsea B.NinjaTrader Customer Service

              Comment


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


                if (barsType == null)
                return;

                double Cpoc = barsType.Volumes[CurrentBar].GetMaximumVolume(null, out price );
                double Ppoc = barsType.Volumes[CurrentBar].GetMaximumVolume(null, out price );​



                Facing this error

                i was looking for fetch max voulme traded in current candle in cpoc and previous candle in ppoc

                Comment


                  #9
                  Hello siddhugaddi,

                  Declare a double variable with the name price above this.

                  See the example from the help guide.


                  For the previous candle use barsType.Volumes[CurrentBar - 1]. (Ensure that CurrentBar is 2 or greater first)
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Thank You for valuable information sir

                    double Cpoc = barsType.Volumes[CurrentBar-1].GetMaximumVolume(null, out price );
                    double Ppoc = barsType.Volumes[CurrentBar-2].GetMaximumVolume(null, out price );



                    Don't know why
                    Last edited by siddhugaddi; 09-13-2024, 12:22 PM.

                    Comment


                      #11
                      Hello siddhugaddi,

                      To understand behavior, add debugging prints.

                      Print the time of the bar and the value of Cpoc and Ppoc.

                      Below is a link to a support article on adding debugging prints to understand behavior.


                      As you are using CurrentBar minus 2, ensure that CurrentBar is 3 or greater before using these indexes.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        I have checked the output
                        In Ppoc and Cpoc its storing the total number of bid ask values
                        Last edited by siddhugaddi; 09-13-2024, 12:23 PM.

                        Comment


                          #13
                          Hello siddhugaddi,

                          You would need to custom calculate this as discussed in post # 7.

                          The DValueArea indicator has a POC line that may give you some ideas.
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            sir i have already checked that process that was not use full for me
                            \i need a last help from you

                            Print("Maximum Combined: " + barsType.Volumes[CurrentBar].GetMaximumVolume(null, out price) + " at price: " + price);



                            How can i do that
                            this is last help sir

                            Last edited by siddhugaddi; 09-13-2024, 12:23 PM.

                            Comment


                              #15
                              Hello siddhugaddi,

                              The price variable holds the value.

                              You could make this a class level variable for just this one method call.

                              private double maxVolPrice;

                              barsType.Volumes[CurrentBar].GetMaximumVolume(null, out maxVolPrice);

                              Print(maxVolPrice);
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by NullPointStrategies, Yesterday, 05:17 AM
                              0 responses
                              71 views
                              0 likes
                              Last Post NullPointStrategies  
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              143 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              76 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              47 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              51 views
                              0 likes
                              Last Post TheRealMorford  
                              Working...
                              X