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

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
    Brandon H.NinjaTrader Customer Service

    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​
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Shai Samuel, 07-02-2022, 02:46 PM
        4 responses
        92 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by DJ888, Yesterday, 10:57 PM
        0 responses
        6 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        158 views
        0 likes
        Last Post loganjarosz123  
        Started by Belfortbucks, Yesterday, 09:29 PM
        0 responses
        7 views
        0 likes
        Last Post Belfortbucks  
        Started by zstheorist, Yesterday, 07:52 PM
        0 responses
        7 views
        0 likes
        Last Post zstheorist  
        Working...
        X