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

MAX with lookback period

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

    MAX with lookback period

    Hello,
    I am going around in circles on a piece of coding that I think should be quite easy. I have a plot, and I want to look back 20 bars at the changes in value from bar 1 to bar 0 and if the current change is higher, take some action. I am not sure about the Input part of the MAX coding.
    Code:
    if (Values[1][0]-Values[1][1] > MAX(?, 20)[0])
    It needs to be > than Values[1][0]-Values[1][1] over the previous 20 bars, but the inputs part of the code where I have the ? will not accept that as an argument.

    Any help would be appreciated.

    Thanks!

    #2
    Originally posted by GeorgeW View Post
    Hello,
    I am going around in circles on a piece of coding that I think should be quite easy. I have a plot, and I want to look back 20 bars at the changes in value from bar 1 to bar 0 and if the current change is higher, take some action. I am not sure about the Input part of the MAX coding.
    Code:
    if (Values[1][0]-Values[1][1] > MAX(?, 20)[0])
    It needs to be > than Values[1][0]-Values[1][1] over the previous 20 bars, but the inputs part of the code where I have the ? will not accept that as an argument.

    Any help would be appreciated.

    Thanks!
    The "?" part of what you have written is to be a Series<T>, so create a Series<double> to hold the difference values, then feed that Series to the MAX() method.

    ref: http://ninjatrader.com/support/helpG...us/seriest.htm

    The last example on that page is a mirror of what you are seeking. You just need to look for a different difference from the one in the example.

    Comment


      #3
      Thanks Koganam,
      I went for a walk to clear my head and figured out I needed to use Series<T> 5 mins into my walk. I'll have to remember to do that more often when I'm stuck. I've done it and my calculations now work.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cmtjoancolmenero, Yesterday, 03:58 PM
      11 responses
      39 views
      0 likes
      Last Post cmtjoancolmenero  
      Started by FrazMann, Today, 11:21 AM
      0 responses
      5 views
      0 likes
      Last Post FrazMann  
      Started by geddyisodin, Yesterday, 05:20 AM
      8 responses
      52 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by DayTradingDEMON, Today, 09:28 AM
      4 responses
      27 views
      0 likes
      Last Post DayTradingDEMON  
      Started by George21, Today, 10:07 AM
      1 response
      22 views
      0 likes
      Last Post NinjaTrader_ChristopherJ  
      Working...
      X