Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

High - Low between 0AM - 8AM

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

    High - Low between 0AM - 8AM

    Hi

    I want to try to use as triggers in my strategy the high - low price made between 0AM - 8AM (my local time). Eventually, I could use the high - low of the first 8 hourly bars.
    How can I put this into code?

    Many thanks

    #2
    This reference might provide some idea - http://www.ninjatrader-support.com/v...ead.php?t=3223
    RayNinjaTrader Customer Service

    Comment


      #3
      According to this example, if I use 60min bars, I will have to set up 8 bars to get the high and low of the session to get high and low for the 0AM - 8AM period.

      If I change bar frequency I will have to change the code every time. There isn't a simpler way to look for the high and low between 0AM and 8AM disregarding the bar frequency?

      Thank you

      Comment


        #4
        There are many ways to do it. If you are not satisfied with any of our reference samples, then you would have to get creative and think of other ways.

        I did just create a new reference sample demonstrating another approach.

        RayNinjaTrader Customer Service

        Comment


          #5
          Thank you, Ray.

          Regarding your Sample, just to make sure:

          1) If I want to use the interval 0AM - 8AM, I will have to substitute 0AM with "StartHour, StartMinute" in your code? In what format should I put the time?

          2) If I want to refer to those values in a strategy, should I refer to the high as SampleGetHighLowByTimeRange.HighestHigh ?

          Thank you again for your precious help

          Comment


            #6
            Correct, a zero. Not sure what you mean by format. Don't use the indicator as a way to get the values. The indicator is just a demonstration of how to accomplish this. Take the code sample and integrate it into your own indicator or strategy.
            RayNinjaTrader Customer Service

            Comment


              #7
              Regarding the format, I meant 0:00 for 0AM and 8:00 for 8AM?

              Thank you for help

              Comment


                #8
                In my code sample, the hour is represented by integer as is the minutes. So 8 AM is 8 for the hour and 0 for the minutes.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  To integrate the indicator into my strategy, should I paste it into the Initialize() method?

                  Thank you

                  Comment


                    #10
                    No, do not integrate the indicator.

                    - You have to open the reference sample provided as an indicator
                    - Look at the logic of how it works
                    - Take this concept/logic, use it in your own NinjaScript objects
                    RayNinjaTrader Customer Service

                    Comment


                      #11
                      After generating a new series (Value), I added the following to your code:

                      // Set the plot values
                      //HighestHigh.Set(highestHigh);
                      //LowestLow.Set(lowestLow);

                      Value.Set( 0 );

                      if (Close[0] > highestHigh)

                      {
                      Value.Set ( 1 );
                      }

                      if (Close[0] < lowestLow)

                      {
                      Value.Set ( -1 );
                      }

                      Then I built a simple strategy (through the wizard) which goes long if the Value is 1 and goes short if the value is -1.

                      It doesn't work though. If I try to plot the indicator, it doesn't plot anything. Why?

                      Thank you

                      Comment


                        #12
                        Sorry, I don't know. The reference sample code and logic works I know that for sure. You will need to dig in and figure out why your code is not working as you expect.
                        RayNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        605 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        351 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        105 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        560 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        561 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X