Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exponential ATR

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

    Exponential ATR

    Hi,

    I'm trying to create an Exponential ATR indicator based on a Daily chart which I will be referencing from within my strategy running against an Hourly chart. Here's what I've achieved so far which, given that I'm posting here, isn't working.

    protected override void Initialize()
    {
    Add(PeriodType.Day,1); //BarsArray[1]
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 1)
    return; // Ignore change to Daily Bar

    if (CurrentBar == 0)
    Value.Set(Highs[1][0] - Lows[1][0]);
    else
    {
    double trueRange = Highs[1][0] - Lows[1][0];
    trueRange = Math.Max(Highs[1][0],Closes[1][1]) - Math.Min(Lows[1][0],Closes[1][1]);
    Value.Set((trueRange - Value[1]) * ( 2/(1 + Period)) + Value[1]);
    }
    }

    I modeled this after the standard ATR indicator. What I have read in the manual suggests that this is the way to access a different chart's data, but NT7 really doesn't seem to want to do it. I don't care about seeing a plot, I just need to resulting double value.

    When I try to reference this from within my strategy using double thisATR = myATR[0] I'm getting the error message "Cannot apply indexing with [] to an expression of type 'method group'" when I attempt to compile. Google doesn't know anything about that error, and neither do I.

    Any thoughts?

    Thanks in advance for your assistance.
    Last edited by cmt_Robert; 04-28-2016, 11:40 AM.

    #2
    Hello cmt_Robert,

    Thank you for writing in.

    Based on the error message you have provided, it looks like you are attempting to call the myATR indicator method, but you have not placed parenthesis. You'll need parenthesis to call a method.

    Example:
    Code:
    double thisATR = myATR(....)[0];
    If your indicator accepts parameters, then you will need to be sure to pass the parameters needed.

    As an example with the SMA indicator...
    Code:
    double thisSMA = SMA(20)[0];
    ...where 20 would be the required period parameter.

    The parameters will be the properties contained within the Properties region of your indicator.

    Once you have placed that open parenthesis, the IntelliPrompt will appear showing what is needed to be passed to the method call.

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your prompt response, ZacharyG!

      You are absolutely correct, and thank you for not saying "you idiot" anywhere in your response.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      579 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      554 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X