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 geddyisodin, Today, 05:20 AM
      3 responses
      20 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by lorem, Today, 09:18 AM
      1 response
      4 views
      0 likes
      Last Post lorem
      by lorem
       
      Started by bmartz, Today, 09:30 AM
      0 responses
      3 views
      0 likes
      Last Post bmartz
      by bmartz
       
      Started by GussJ, 03-04-2020, 03:11 PM
      14 responses
      3,245 views
      0 likes
      Last Post GussJ
      by GussJ
       
      Started by ArkansasClint, Today, 09:28 AM
      0 responses
      2 views
      0 likes
      Last Post ArkansasClint  
      Working...
      X