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);
    }
    }
    })); 

    #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 Market1337, Today, 08:54 AM
    0 responses
    13 views
    0 likes
    Last Post Market1337  
    Started by Bobin, Today, 04:29 AM
    1 response
    13 views
    0 likes
    Last Post bltdavid  
    Started by Lyubomir Kratinov, Today, 06:36 AM
    2 responses
    17 views
    0 likes
    Last Post Lyubomir Kratinov  
    Started by joostb, Today, 12:59 AM
    2 responses
    12 views
    0 likes
    Last Post joostb
    by joostb
     
    Started by Shai Samuel, Today, 02:35 AM
    0 responses
    12 views
    0 likes
    Last Post Shai Samuel  
    Working...
    X