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

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 rocketman7, Today, 01:00 AM
      0 responses
      1 view
      0 likes
      Last Post rocketman7  
      Started by wzgy0920, 04-20-2024, 06:09 PM
      2 responses
      27 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, 02-22-2024, 01:11 AM
      5 responses
      32 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, 04-23-2024, 09:53 PM
      2 responses
      74 views
      0 likes
      Last Post wzgy0920  
      Started by Kensonprib, 04-28-2021, 10:11 AM
      5 responses
      193 views
      0 likes
      Last Post Hasadafa  
      Working...
      X