Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

High/low based on duration

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

    High/low based on duration

    Hi Support/Ninjausers

    Basic question,..is there like a function (or something similar to build upon) for getting the high/low/close/open based on the duration. For example on a 24 hour ES 610 tick chart, High( 13:00,16:15) gives the high of ES,between 1:00 pm and 4:00 pm.

    Thanks
    RK

    #2
    Please see this reference sample. You can use the technique outlined there to determine the values you want: http://www.ninjatrader-support.com/v...ead.php?t=3223
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hi Josh

      I've been trying to use this indicator code - SampleBreakOutStrategy - in my strategy. But I think my problem is that I want to draw my barriers starting from 18.00 on the previous day to 01.30 the current day - this code doesn't work for that. Do you have any suggestions? All I want do is establish the highest high and lowest low between those periods, to trade a breakout from that.

      Thanks!

      Comment


        #4
        In that case you will want to kind of play with the Time[0] variable and squeeze out a high/low from that bar range. This reference sample is not exactly what you want, but may shed some light as to how to proceed: http://www.ninjatrader-support.com/v...ead.php?t=3226
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thanks Josh, but I've been playing around with that one too for a week and I can't seem to figure anything out with it - have you got any suggestions?

          I'm sure there must be a solution because if I run the strategy analyser with a strategy and punch in the time 18:00 for session start and 2:00 for session end, NT does immediately recognise that this means 18:00 the previous day to 2:00 today...so there must be an underlying facility for NT to recognise that - but I can't find any code anywhere that might show that.

          I've also been playing with PriorDayOHLC - but I don't have enough examples of any of these that can give me some insight into how to use them.

          Comment


            #6
            Unfortunately there is no reference sample available. You have to program it with if statements and maybe some loops.

            Make a loop to go through the time period you want and just save the High and Low values. Compare it with itself everytime it comes back for a loop and modify those values if it is a new high or a new low.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Josh, thanks for your patience, sorry to sound dumb - but I'm not sure how to do that in relation to the issue of getting to yesterday's time period. Is there anything I could use like ToDay or DayofWeek for this - like "yesterday" or "priorday" which establishes any particular time on the previous day?
              Last edited by Red Fish; 09-04-2008, 12:21 AM.

              Comment


                #8
                I've even tried SampleGetHighLowByTimeRange to count candles backwards from 1.00am, by making endBarsAgo start at 1.00 and then doing a calculation for startBarsAgo as endBarsAgo - 84;

                But this doesn't work, it plots counting forward to midnight where it breaks, then has a gap and starts plotting counting forward again at 1.00am.
                Last edited by Red Fish; 09-04-2008, 07:49 AM.

                Comment


                  #9
                  Hi Red Fish,

                  No problem at all. Good question. One of our personnel in NinjaScript training will respond with some code later on in the day. Thanks for waiting.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Hello,

                    Try something like this:


                    if(ToTime(Time[0]) == myStartTime)
                    {

                    for (int i = 0; i <= CurrentBar; i++)
                    {

                    if(ToTime(Time[i]) == myEndTime)
                    break;


                    if(hh < High[i])
                    {
                    hh = High[i];
                    }


                    if(ll > Low[i])
                    {
                    ll = Low[i];
                    }
                    }
                    }

                    This link will help:


                    This link also:

                    DenNinjaTrader Customer Service

                    Comment


                      #11
                      Thanks Ben and Josh, I'll try it out!

                      Comment


                        #12
                        Take note that myStartTime and myEndTime are integers. If you wanted 9:30 you would have one of the times set to 93000.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Hi Ben and Josh, here is what I did with your code, could you have a look and see please?

                          It does something strange, the high doesn't come out as the high time range for that date, and the low comes out as zero.
                          Attached Files

                          Comment


                            #14
                            You want previous day's 6pm to current day's 1am? Or 1am - 6pm today?

                            myStartTime should be the time you want to stop. Everything looks historically. For example:

                            Current Time = 3pm
                            Want to get HH and LL from 3pm back to yesterday's 5pm
                            myStartTime = 150000
                            myEndTime = 170000

                            There may be time frames that might get awry though. For instance, 3pm today back to yesterday's 1pm. The current code will only go from 3pm back to today's 1pm. Hope you do not need such a case.
                            Last edited by NinjaTrader_JoshP; 09-04-2008, 12:23 PM.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Hi Josh

                              Yes, I tried that, I made my start time as 010000 and my end time as 180000 - but it still doesn't work. Any clues?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              671 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              379 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              111 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              575 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              582 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X