• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing tool: access value calculated by indicator

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

    Drawing tool: access value calculated by indicator

    Hi,

    I created a couple of indicators and a couple of drawing tools for NT8.
    I need to create a custom drawing tool that needs to read a value calculated by an indicator (the indicator also output the value in the Data Box). The indicator value would be used to create the shape of the drawing tool.
    How can I do that?
    I know how to read the data series values but after searching for many hours on this forum, reading the help guide and trying everything that came to my mind have yet to find how to read indicator output value from a custom drawing tool.

    Thank you

    #2
    Hello PriceSurfer,

    Thanks for your question.

    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 so you can reference the plot with GetValueAt(). You can get the barIndex by checking the coordinate and using ChartBars.GetBarIdxByX().

    You could try the following in your OnMouseDown method:

    Code:
    ChartObjectCollection<NinjaTrader.Gui.NinjaScript.IndicatorRenderBase> indicatorCollection = chartControl.Indicators;
    Point point = dataPoint.GetPoint(chartControl, chartPanel, chartScale);
    int barIndex = GetAttachedToChartBars().GetBarIdxByX(chartControl, (int)point.X);
    
    foreach (NinjaTrader.Gui.NinjaScript.IndicatorRenderBase indicator in indicatorCollection)
    {
        if (indicator.Name == "TargetIndi")
            Print((indicator as NinjaTrader.NinjaScript.Indicators.TargetIndi).IndiPlot.GetValueAt(barIndex));
    }
    Publicly available documentation on these items is linked below:

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

    GetAttachedToChartBars - https://ninjatrader.com/support/help...ochartbars.htm

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

    GetValueAt() - https://ninjatrader.com/support/help...getvalueat.htm

    Please let us know if we can be of further assistance.
    Attached Files
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by bcgeek, Today, 03:43 PM
    2 responses
    5 views
    0 likes
    Last Post bcgeek
    by bcgeek
     
    Started by Mberg, Today, 04:05 PM
    0 responses
    6 views
    0 likes
    Last Post Mberg
    by Mberg
     
    Started by dkbyond, Today, 03:52 PM
    0 responses
    2 views
    0 likes
    Last Post dkbyond
    by dkbyond
     
    Started by Newtrader101, Today, 03:09 PM
    2 responses
    4 views
    0 likes
    Last Post Newtrader101  
    Started by Austiner87, Today, 02:56 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X