• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting the max price from the past x ticks

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

    Getting the max price from the past x ticks

    I'm trying to get the max price from the past x number of ticks but I just don't know how to write that into the script. Ideally I would want to use something like maxbars = max.bars[5]; and this example would be looking at the past 5 ticks to get the max price, but I am not getting the max price from this and am stuck. Where am I messing up?
    Last edited by jertrade; 07-17-2019, 02:57 PM.

    #2
    Hello jertrade,

    Can you provide more detail about how this code would be used and executed? Are you using a 1 tick series or something else?

    On a 1 tick series, you could just use the Max indicator with a lookback of 5. If you are using a different time frame, you would need to create logic to gather the last 5 ticks and then see which is the biggest number of those 5 numbers. You can do that in a variety of ways, most would involve a loop and a variable which denotes the currently found max value. For this question, I would suggest doing a general web search for C# solutions as well. For example "C# find max value of array" or "C# find max value of List" are a couple of more simple ways to approach this concept.

    If you have tried something which is not working, it also helps to provide a specific example instead of pseudo code.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      On a 1 tick series, you could just use the Max indicator with a lookback of 5. If you are using a different time frame, you would need to create logic to gather the last 5 ticks and then see which is the biggest number of those 5 numbers.
      I am thinking, because I am building a scalping script, about using ticks. I thought about using seconds or minutes but I think that I am going to miss out on too many opportunities. Given this information, what would the syntax be for the Max indicator with a look back of 5 be? I cannot seem to find it.

      Comment


        #4
        Hello jertrade,

        You can find a sample of the MAX here:
        https://ninjatrader.com/support/help...aximum_max.htm

        Assuming the series being used is a 1 tick series, the syntax would be the same as the sample replacing the 20 with 5 for your use case.



        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by buick, Today, 09:37 PM
        0 responses
        4 views
        0 likes
        Last Post buick
        by buick
         
        Started by Hagar, Today, 07:12 PM
        0 responses
        6 views
        0 likes
        Last Post Hagar
        by Hagar
         
        Started by jtrading82, Today, 01:55 PM
        4 responses
        28 views
        0 likes
        Last Post bppayne
        by bppayne
         
        Started by Hagar, Today, 06:52 PM
        0 responses
        4 views
        0 likes
        Last Post Hagar
        by Hagar
         
        Started by vivekniwas, Today, 04:56 PM
        0 responses
        7 views
        0 likes
        Last Post vivekniwas  
        Working...
        X