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 trilliantrader, 04-18-2024, 08:16 AM
      7 responses
      27 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by samish18, 04-17-2024, 08:57 AM
      17 responses
      64 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by rocketman7, Today, 02:12 AM
      2 responses
      17 views
      0 likes
      Last Post rocketman7  
      Started by briansaul, Today, 05:31 AM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by PaulMohn, Today, 03:49 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Working...
      X