• 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 ajsdnyyrr1234DDf, Today, 09:39 AM
    0 responses
    5 views
    0 likes
    Last Post ajsdnyyrr1234DDf  
    Started by afoschini, Today, 09:18 AM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_Jim  
    Started by rexsole, Today, 08:02 AM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_PatrickG  
    Started by johnnybegoode, Yesterday, 07:06 PM
    1 response
    18 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by johnnybegoode, Yesterday, 10:06 PM
    1 response
    13 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X