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

Get ATR of Instrument from Addon

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

    Get ATR of Instrument from Addon

    Hello,

    I'm trying to get the ATR value of an Instrument from an Addon.

    So, i try to get ATR indicator without success.

    An finally i tried to compute the ATR in a BarRequest but the returned value is false.

    Can you maybe help me to find the good value ?

    Here my sample:
    PHP Code:
    barsRequest.Request(new Action<BarsRequestErrorCodestring>((barserrorCodeerrorMessage) =>
    {
    for (
    int i 0bars.Bars.Counti++)
    {
    double high0 bars.Bars.GetHigh(i);
    double low0 bars.Bars.GetLow(i);

    if (
    == 0)
    {
    _atr.Add(high0 low0);
    }
    else
    {
    double close1 bars.Bars.GetClose(i-1);
    double trueRange Math.Max(Math.Abs(low0 close1), Math.Max(high0 low0Math.Abs(high0 close1)));
    double value = ((Math.Min(1Period) - ) * _atr[_atr.Count-1] + trueRange) / Math.Min(1Period);
    _atr.Add(value);
    NinjaTrader.Code.Output.Process(string.Format("val ue: {0}"value), PrintTo.OutputTab1);
    }
    }
    })); 
    johnok
    NinjaTrader Ecosystem Vendor - Trade With Me

    #2
    Hello johnok,

    Thank you for the question.

    Indicators can't be called from an addon so to calculate an ATR you would essentially need to copy over the logic from the ATR and remake it using the bars request. There are no Series or any other bar related mechanics in an addon, the BarsRequest would be the primary way for an addon to get historical data or subscribe to realtime data.

    An finally i tried to compute the ATR in a BarRequest but the returned value is false.
    I am not certain I understand what you mean by it returns false, are you referring to the bars request returning false? Your calculation logic would have to go within the bars request and you would need to use a private class level variable to store the result so it can be used outside the bars request.

    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Stanfillirenfro, Yesterday, 09:19 AM
    7 responses
    51 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by TraderCro, 04-12-2024, 11:36 AM
    4 responses
    69 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Mindset, Yesterday, 02:04 AM
    1 response
    15 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by agclub, 04-21-2024, 08:57 PM
    4 responses
    18 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by Irukandji, Today, 04:58 AM
    0 responses
    6 views
    0 likes
    Last Post Irukandji  
    Working...
    X