Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Access chart indicator data using drawing tool

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

    Access chart indicator data using drawing tool

    Hello,

    I created a drawing tool that allows the user to highlight over a range of bars to gather and print it's volume and delta onto the chart. The drawing tool is used only on volumetric bars. I want to take it a step further and add this feature:

    On the same chart I am using the drawing tool, I have a configured Order Flow Volume Profile indicator displayed as well. When my drawing tool is displayed onto the chart I would like the tool to reference the Value Area High and Value Area Low from my configured volume profile. In my Drawing Tool's highlighted range, if the VPOC of a bar is above or equal to the value area high, add bar index to "Above Value Group". Bar VPOCs in the value range and below value will be grouped respectively as well. This way, if I were to highlight over a large intraday range, the drawing tool will easily separate the activity that happens in each of the three value areas of my configured volume profile.

    In order for me to access my configured volume profile's data, what are some best practices to reference indicator data using a drawing tool?

    #2
    Hello Don22Trader1,

    Thanks for your post.

    You'll have to loop through the chart's Indicators collection to find your target indicator, and then you can cast that base indicator as your target indicator class.

    Indicators collection: https://ninjatrader.com/support/help...indicators.htm

    This forum thread details this topic and has a simple example script you could view: https://forum.ninjatrader.com/forum/...13#post1041713

    Note that Order Flow Volume Profile is not exposed for NinjaScript access.

    You would need to create a custom indicator that calculates the Value Area High and Value Area Low values.

    This forum thread details calculating Value Area High and Value Area Low: https://forum.ninjatrader.com/forum/...79#post1112679
    <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


      #3
      I downloaded the DValueArea indictor to have easier access to value area plots. The values from this indicator can be slightly off from the Order Flow Volume Profile indicator but it is close enough to get the job done. I am running into a problem when accessing the VAt & VAb values from DValueArea. Below is a snippet of what I have so far:

      Code:
      OnRender()
      {
      ChartObjectCollection<NinjaTrader.Gui.NinjaScript. IndicatorRenderBase> indicatorCollection = chartControl.Indicators;
      
      Point startPoint = StartAnchor.GetPoint(chartControl, chartPanel, chartScale);
      Point endPoint = EndAnchor.GetPoint(chartControl, chartPanel, chartScale);
      int startIdx = myBars.GetBarIdxByX(chartControl, (int)startPoint.X);
      int endIdx = myBars.GetBarIdxByX(chartControl, (int)endPoint.X);​
      
      foreach (NinjaTrader.Gui.NinjaScript.IndicatorRenderBase indicator in indicatorCollection)
      {
      if (indicator.Name == "DValueArea")
      {
      double VAH = ((indicator as NinjaTrader.NinjaScript.Indicators.DValueArea).VAt .GetValueAt([B]?[/B]));
      
      
      Print("1");
      
      }
      }
      The "double VAH = ..." line is what is causing the problem because when I use the drawing tool without this line of code the "1" print appears in the output.​ The startIdx & endIdx are used for getting the start and end bar index of the highlighted bar range of the drawing tool for other calculations. However; I do not understand how to refer to the correct bar index for getting the VAt & VAb values from the DValueArea Indicator.

      Comment


        #4
        Hello Don22Trader1,

        Thanks for your notes.

        You can get the barIndex by checking the coordinate and using ChartBars.GetBarIdxByX().

        Then, that bar index could be passed into GetValueAt(int barIndex).

        This forum post from my colleague Jim contains sample code demonstrating this concept or checking the coordinate and using ChartBars.GetBarIdxByX() to get the bar index: https://forum.ninjatrader.com/forum/...13#post1041713

        You would need to figure out what bars you wanted the values for and use those bar indexes. Unlike a notmal indicator or strategy script, you wouldn't e able to just use the whole indicator plot. You could use the start/end anchor's index if you wanted the value on that bar.

        GetAttachedToChartBars - https://ninjatrader.com/support/helpGuides/nt8/getattachedtochartbars.htm

        ChartBars.GetBarIdxByX - https://ninjatrader.com/support/help...tbaridxbyx.htm

        GetValueAt() - https://ninjatrader.com/support/help...eat.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

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        596 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        343 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        556 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        554 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X