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

Find the High and Low every 15 minutes

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

    Find the High and Low every 15 minutes

    i need to create an indicator which can find the high and low every 15 minutes

    #2
    Hello calmsoul,

    We have a reference sample that is close to this:
    Indicator: Calculating the highest high or lowest low for a specified time range
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      code

      thank for your quick response i have been using that as reference i am stuck where my highs and lows are not getting populated. Below is the code i have. Any idea why high and lows are not printing

      time = DateTime.Now; // get the current time
      // condition if time <15

      if (time.Minute<15){ // check if time is less than 15 minutes

      startHour = time.Hour;
      // Default setting for StartHour
      Print("condition is less than 15");
      Print(
      "Current hour is:" + time.Hour);
      startMinute =
      00; // Default setting for StartMinute
      endHour = time.Hour; // Default setting for EndHour
      endMinute = 15; // Default setting for EndMinute
      if (ToTime(EndHour, EndMinute, 0) > ToTime(time))
      return;
      else {
      calculatesr(StartHour, StartMinute, EndHour, EndMinute);
      }

      Comment


        #4
        Calculatesr function

        //below is the calculatesr function

        publicvoid calculatesr(int StartHour, int StartMinute, int EndHour, int EndMinute)
        {
        if (startDateTime.Date != Time[0].Date)
        {
        startDateTime =
        new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, StartHour, StartMinute, 0);
        endDateTime =
        new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, EndHour, EndMinute, 0);
        }

        Print(
        "start hour in function is" + StartHour);
        Print(
        "start minute in function is" + StartMinute);
        Print(
        "end minute in function is" + EndMinute);

        // Calculate the number of bars ago for the start and end bars of the specified time range
        int startBarsAgo = GetBar(startDateTime);
        int endBarsAgo = GetBar(endDateTime);

        double highestHigh = MAX(High, startBarsAgo - endBarsAgo)[endBarsAgo];

        double lowestLow = MIN(Low, startBarsAgo - endBarsAgo)[endBarsAgo];

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



        }

        Comment


          #5
          That reference sample is useful for making these types of calculations every day. If you only care about the last 15 minutes(Compared to CurrentTime), you can simplify a bit.

          Use GetBar to get the bars ago value for 15 minutes ago and plug that in for your barsago parameter in MIN and MAX.

          int fifteenMinutesAgo = GetBar(DateTime.Now.AddMinutes(-15));
          double myHigh = MAX(High, fifteenMinutesAgo)[0];

          This will only return useful values for the most recent 15 minutes. Prior to that, any value return is the individual bar highs and lows.
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            thanks for your referece. I want to capture high and lows within an hour every 14 minutes for example between 9 and 10 i want the following:

            9:00-9:15
            9:15:9:30
            9:30-9:45
            9:45-10

            Comment


              #7
              I see - you want a rolling 15 minute high / low. You'll will want to use Time[0] instead of DateTime.Now. This captures the bar time stamp, not your computer date / time.


              int fifteenMinutesAgo = GetBar(Time[0].AddMinutes(-15));
              double myHigh = MAX(High, fifteenMinutesAgo)[0];
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                I am looking for this type of indicator but I do not understand how you guys program to achieve it. Do you have a completed indicator available for download? I like the 15 minute TF and would like to have H/L appear on a continuous rolling basis.
                thank you

                Comment


                  #9
                  bowas, we would unfortunately not have this completed as a sample study, you would need to code it out yourself with the snippet as starting point that Ryan provided - http://www.ninjatrader.com/support/h...indicators.htm
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    need help with simple plotting indicators

                    Originally posted by calmsoul View Post
                    i need to create an indicator which can find the high and low every 15 minutes
                    I am looking for something that will do this also. Any help is appreciated. While I am at it, I also would like an indicator that will draw a vertical line every "x" bars also. i.e. a vertical bar every 15 1 minute bars. I am looking for both a vertical plot to divide trading into 15 bar (1 minute bars) increments, and an indicator that will draw a horizontal line at the highest high and lowest low of "x" period bars. Trying do get small breakouts of small parts of day. Thanks in advance. I use v 6.5

                    Comment


                      #11
                      smartguy, you can draw vertical lines using the DrawVerticalLine() method. You could draw this every 15 minutes (starting on the hour), like this:
                      Code:
                      if (Time[0].Minute % 15 == 0)
                          DrawVerticalLine("vert line" + CurrentBar, 0, Color.Black, DashStyle.Solid, 2);
                      This code takes the minute component of the current bar's time, divides it by 15, and if the remainder is 0, then it draws the line.
                      Attached Files
                      AustinNinjaTrader Customer Service

                      Comment


                        #12
                        thanks to begin with

                        I want to begin by thanking your for responding and offering your help. I hate to seem stupid, but how do I make that in to an indicator- I tried "creating indicator" and copy pasting this in- no luck- I am capable of importing or copy pasting an already created .cs file if you could help me with that I would be very appreciative. Thanks in advance
                        Originally posted by NinjaTrader_Austin View Post
                        smartguy, you can draw vertical lines using the DrawVerticalLine() method. You could draw this every 15 minutes (starting on the hour), like this:
                        Code:
                        if (Time[0].Minute % 15 == 0)
                            DrawVerticalLine(&quot;vert line&quot; + CurrentBar, 0, Color.Black, DashStyle.Solid, 2);
                        This code takes the minute component of the current bar's time, divides it by 15, and if the remainder is 0, then it draws the line.

                        Comment


                          #13
                          smartguy,

                          You should be able to create a custom indicator from this snippet.

                          Click Tools > New NinjaScript > Indicator
                          All defaults are acceptable. Click Next through the wizard until you get to the code view.
                          Place the snippet so that it falls in-between the two curly bracket { } of OnBarUpdate(), like this:

                          Code:
                           protected override void OnBarUpdate()
                           {
                          	if (Time[0].Minute % 15 == 0)
                           	DrawVerticalLine("vert line" + CurrentBar, 0, Color.Black, DashStyle.Solid, 2);
                           }
                          There is one property you might want to change in Initalize()
                          Overlay = true; //means the indicator is placed on the main price panel

                          You also don't need a plot value so you can delete or comment the line that sets the plot.
                          Last edited by NinjaTrader_RyanM1; 12-07-2010, 11:52 AM.
                          Ryan M.NinjaTrader Customer Service

                          Comment


                            #14
                            thank you

                            thank you for your kindness. Now how do I make it display all the way up and down panal 1 (price) rather then only on the price bar. I think it probably has something to do with the code calling for black and I use a black chart background, but when I tried to change the color in the code it won't compile, and if I stipulate a color in the indicator, it doesn't change color. I am sure it is something very simple, but I am just not up to speed in the ninja coding language.
                            Originally posted by NinjaTrader_RyanM View Post
                            smartguy,

                            You should be able to create a custom indicator from this snippet.

                            Click Tools > New NinjaScript > Indicator
                            All defaults are acceptable. Click Next through the wizard until you get to the code view.
                            Place the snippet so that it falls in-between the two curly bracket { } of OnBarUpdate(), like this:

                            Code:
                             protected override void OnBarUpdate()
                             {
                                if (Time[0].Minute % 15 == 0)
                                 DrawVerticalLine(&quot;vert line&quot; + CurrentBar, 0, Color.Black, DashStyle.Solid, 2);
                             }
                            There is one property you might want to change in Initalize()
                            Overlay = true; //means the indicator is placed on the main price panel

                            You also don't need a plot value so you can delete or comment the line that sets the plot.
                            Last edited by smartguy; 12-07-2010, 02:37 PM.

                            Comment


                              #15
                              Originally posted by NinjaTrader_RyanM View Post
                              I see - you want a rolling 15 minute high / low. You'll will want to use Time[0] instead of DateTime.Now. This captures the bar time stamp, not your computer date / time.


                              int fifteenMinutesAgo = GetBar(Time[0].AddMinutes(-15));
                              double myHigh = MAX(High, fifteenMinutesAgo)[0];
                              Instead of a rolling time period, how does one make it a 15 minute time period. Like 9:00 to 9:15, 9:15 to 9:30, etc?

                              Seems like calmsoul's original question has not been addressed: "i need to create an indicator which can find the high and low every 15 minutes"

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by wzgy0920, 04-20-2024, 06:09 PM
                              2 responses
                              26 views
                              0 likes
                              Last Post wzgy0920  
                              Started by wzgy0920, 02-22-2024, 01:11 AM
                              5 responses
                              32 views
                              0 likes
                              Last Post wzgy0920  
                              Started by wzgy0920, Yesterday, 09:53 PM
                              2 responses
                              49 views
                              0 likes
                              Last Post wzgy0920  
                              Started by Kensonprib, 04-28-2021, 10:11 AM
                              5 responses
                              192 views
                              0 likes
                              Last Post Hasadafa  
                              Started by GussJ, 03-04-2020, 03:11 PM
                              11 responses
                              3,234 views
                              0 likes
                              Last Post xiinteractive  
                              Working...
                              X