Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetDeltaForPrice error

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

    GetDeltaForPrice error

    Hello,

    I am trying to add volumetric data to my existing strategy but am getting an error. I want to loop through each price of the previous candle and find the highest delta level and the price it occurred at.

    I've added the following code to the State.Configure:

    // Add the the volumetic bar data - BarsInProgress 6
    AddVolumetric("ES 03-23", BarsPeriodType.Minute, 1, VolumetricDeltaType.BidAsk, 1);

    To test, I've added the following to the OnBarUpdate:

    if (BarsInProgress == 6
    && IsFirstTickOfBar == true)
    {
    GetDeltaForPrice(Close[1]);
    }

    I get the error "The name 'GetDeltaForPrice' does not exist in the current context".

    I've tried to find examples of using volumetric bars but the only examples I can find do not use BarsAgo , so I am not sure if I am using it correctly.
    ​​

    #2
    Hello adaisguy,

    Thank you for your note.

    I recommend reviewing the example shown on the help guide page here:


    As you mentioned, this example is not using a BarsAgo reference. The note at the bottom of the page states, "Please note in the example above a CurrentBar reference is used as index, and not a BarsAgo reference." This means that you will need to use a bar index. If you would like the calculation to be based on the previous bar, you may use CurrentBar -1. Here is a snippet based on the volumetric bars being the only added data series. It compares the current Delta for Close with the Delta for Close[1] for bar index CurrentBars[1] - 1:

    Code:
    if (BarsInProgress == 0 || Bars == null || CurrentBars[1] < 10)
    return;
    
    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[1].BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType;
    
    if (barsType == null)
    return;
    
    Print("Delta for Close: " + barsType.Volumes[CurrentBars[1]].GetDeltaForPrice(Closes[1][0]));
    Print("Delta for Close[1] on CurrentBars[1] - 1: " + barsType.Volumes[CurrentBars[1] - 1].GetDeltaForPrice(Closes[1][1]));
    Another helpful resource when working with multi-time frame and instrument scripts is the following:


    Please let us know if we may be of further assistance.

    Comment


      #3
      Thank-you. I was able to get it working.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      52 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      70 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      44 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      48 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X