• 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

Time[0]

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

    Time[0]

    What does the Time function return - the close time or open time of the bar?

    10x

    #2
    kiss,

    Which Time function are you referring to? If you just mean Time this is a dataseries, not a function, and it returns the time stamp of the bars on your chart.

    For example Time[0] is the time stamp of the most recent bar.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Yes, I refer to the bar time stamp. Is that the bar open time or close time?

      10x

      Comment


        #4
        Hello kiss987,
        NinjaTrader stamps a bar with the closing time of the bar.

        Please refer to our help guide to know more about it.
        http://www.ninjatrader.com/support/h..._are_built.htm
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          This is causing me a problem with one of my indicators. Maybe you can help me resolve this problem.

          I have a indicator which I can set the pit traded hours for plotting of the data. Lets say the ES pit which begins are 09:30 est. If I put 09:30 in the start time on a 1minute chart then it gives an incorrect start time, the plotting starts one minute early, I have to put 0931 as the start time to manually create the offset. On a 5min chart I have to input 0935 as the start time... etc etc. At first I couldnt work out why, the ninja time stamping explains this. Ok, thatīs fine, understood....... but...

          What do I need to do to the indicator in the code to auto allow for this "chart timeframe" offset?

          At the moment to make the indicator start plotting at the correct time I have to add the number of minutes that equals the time frame of the chart...This is annoying when changing the chart time-frame numerous times daily, I have to change the indicator properties as well every time making this very cumbersome. I have other indicators (like my value area indie) which I can define the start time, and I simply put the exact time into that one, as it should be...

          I assume there is some form of "time-chart timeframe offset" that can be written into the indicator?

          Thanks for your help.

          Comment


            #6
            Originally posted by ScottieDog View Post
            This is causing me a problem with one of my indicators. Maybe you can help me resolve this problem.

            I have a indicator which I can set the pit traded hours for plotting of the data. Lets say the ES pit which begins are 09:30 est. If I put 09:30 in the start time on a 1minute chart then it gives an incorrect start time, the plotting starts one minute early, I have to put 0931 as the start time to manually create the offset. On a 5min chart I have to input 0935 as the start time... etc etc. At first I couldnt work out why, the ninja time stamping explains this. Ok, thatīs fine, understood....... but...

            What do I need to do to the indicator in the code to auto allow for this "chart timeframe" offset?

            At the moment to make the indicator start plotting at the correct time I have to add the number of minutes that equals the time frame of the chart...This is annoying when changing the chart time-frame numerous times daily, I have to change the indicator properties as well every time making this very cumbersome. I have other indicators (like my value area indie) which I can define the start time, and I simply put the exact time into that one, as it should be...

            I assume there is some form of "time-chart timeframe offset" that can be written into the indicator?

            Thanks for your help.
            So just programatically add the time for one bar to the start time. You can get the current bar timeframe/period using the necessary NT function.

            ref: http://www.ninjatrader.com/support/h...barsperiod.htm

            Of course, you must remember that the bars period is only fixed if you are using fixed-time bars. I, for example trade off Range Bars, so would not have the problem that you describe. I used fixedperiod bars for targeting, but that is another kettle of fish.

            Comment


              #7
              Hi,

              It sounds like its an easy fix, but iīve looked at the page you referenced and really have no idea what to do. Can you tell me what code I have to input, and where inside the script?

              Comment


                #8
                Originally posted by ScottieDog View Post
                Hi,

                It sounds like its an easy fix, but iīve looked at the page you referenced and really have no idea what to do. Can you tell me what code I have to input, and where inside the script?
                I cannot tell you that because I do not know what you have coded. I would at least have to know how you coded your start time, that leaves you unsatisfied. My coding style is unlikely to be the same as yours, so I cannot show you what to do in a vacuum.

                Comment


                  #9
                  Hi Koganam,

                  Here is the code below... Any help appreciated.

                  I didnīt do it myself, I paid someone to do it and this is what they made of it.. They now decline to fix it.. Maybe he doesnīt know how, heīs certainly not being very friendly about it. I mentioned to him before about the time being 1min off (or the time frame of the chart) and he said "that was normal"...


                  Code:
                   {
                          #region Variables
                  
                          // Wizard generated variables
                          // User defined variables (add any user defined variables below)
                          private DateTime     currentDate     = Cbi.Globals.MinDate;
                          private double        currentOpen        = 0;
                          private double        currentHigh        = 0;
                          private double        currentLow        = 0;
                          private double        currentClose    = 0;
                          private double        priordayOpen    = 0;
                          private double        priordayHigh    = 0;
                          private double        priordayLow        = 0;
                          private double        priordayClose    = 0;
                          private bool        showOpen        = true;
                          private bool        showHigh        = true;
                          private bool        showLow            = true;
                          private bool        showClose        = true;
                          #endregion
                  
                          int dayStart = 800;
                          int dayEnd = 2200;
                          int onDay = 0;
                          /// <summary>
                          /// This method is used to configure the indicator and is called once before any bar data is loaded.
                          /// </summary>
                          protected override void Initialize()
                          {
                              Add(new Plot(Color.Orange, PlotStyle.Hash, "Prior Open"));
                              Add(new Plot(Color.Green, PlotStyle.Hash, "Prior High"));
                              Add(new Plot(Color.Red, PlotStyle.Hash, "Prior Low"));
                              Add(new Plot(Color.Firebrick, PlotStyle.Hash, "Prior Close"));
                  
                              Plots[0].Pen.DashStyle = DashStyle.Dash;
                              Plots[3].Pen.DashStyle = DashStyle.Dash;
                              
                              AutoScale             = false;
                              Overlay                = true;      // Plots the indicator on top of price
                          }
                  
                          /// <summary>
                          /// Called on each bar update event (incoming tick)
                          /// </summary>
                          protected override void OnBarUpdate()
                          {
                              if (Bars == null)
                                  return;
                  
                              if (!Bars.BarsType.IsIntraday)
                              {
                                  DrawTextFixed("error msg", "PriorDayOHLC only works on intraday intervals", TextPosition.BottomRight);
                                  return;
                              }
                  
                  
                              //if (onDay != Time[0].Day)
                              //{
                              //    if (currentOpen != 0)
                              //    {
                              //        priordayOpen = currentOpen;
                              //        priordayHigh = currentHigh;
                              //        priordayLow = currentLow;
                              //        priordayClose = currentClose;
                  
                              //        if (ShowOpen) PriorOpen.Set(priordayOpen);
                              //        if (ShowHigh) PriorHigh.Set(priordayHigh);
                              //        if (ShowLow) PriorLow.Set(priordayLow);
                              //        if (ShowClose) PriorClose.Set(priordayClose);
                              //    }
                  
                              //    onDay = Time[0].Day;
                              //}
                              //else
                              //{
                              //}
                  
                              // If the current data is not the same date as the current bar then its a new session
                              if (currentDate != Bars.GetTradingDayFromLocal(Time[0]) || currentOpen == 0)
                              {
                                  // The current day OHLC values are now the prior days value so set
                                  // them to their respect indicator series for plotting
                                  if (currentOpen != 0)
                                  {
                                      priordayOpen = currentOpen;
                                      priordayHigh = currentHigh;
                                      priordayLow = currentLow;
                                      priordayClose = currentClose;
                  
                                      if (ShowOpen) PriorOpen.Set(priordayOpen);
                                      if (ShowHigh) PriorHigh.Set(priordayHigh);
                                      if (ShowLow) PriorLow.Set(priordayLow);
                                      if (ShowClose) PriorClose.Set(priordayClose);
                                  }
                  
                                  // Initilize the current day settings to the new days data
                                  currentOpen = Open[0];
                                  currentHigh = High[0];
                                  currentLow = Low[0];
                                  currentClose = Close[0];
                  
                                  currentDate = Bars.GetTradingDayFromLocal(Time[0]);
                              }
                              else // The current day is the same day
                              {
                                  if (ToTime(Time[0]) == dayStart * 100) currentOpen = Open[0];
                  
                                  if (ToTime(Time[0]) > dayStart * 100 && ToTime(Time[0]) < dayEnd * 100)
                                  {
                                      // Set the current day OHLC values
                                      currentHigh = Math.Max(currentHigh, High[0]);
                                      currentLow = Math.Min(currentLow, Low[0]);
                                      currentClose = Close[0];
                                  }
                  
                                  if (ShowOpen) PriorOpen.Set(priordayOpen);
                                  if (ShowHigh) PriorHigh.Set(priordayHigh);
                                  if (ShowLow) PriorLow.Set(priordayLow);
                                  if (ShowClose) PriorClose.Set(priordayClose);
                              }
                          }
                  
                          #region Properties
                  
                          [Description("")]
                          [Category("Parameters")]
                          public int DayStart
                          {
                              get { return dayStart; }
                              set { dayStart = Math.Max(0, value); }
                          }
                  
                          [Description("")]
                          [Category("Parameters")]
                          public int DayStop
                          {
                              get { return dayEnd; }
                              set { dayEnd = Math.Max(1, value); }
                          }
                  
                          [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                          [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                          public DataSeries PriorOpen
                          {
                              get { return Values[0]; }
                          }
                  
                          [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                          [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                          public DataSeries PriorHigh
                          {
                              get { return Values[1]; }
                          }
                  
                          [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                          [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                          public DataSeries PriorLow
                          {
                              get { return Values[2]; }
                          }
                  
                          [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                          [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                          public DataSeries PriorClose
                          {
                              get { return Values[3]; }
                          }
                          
                          [Browsable(true)]
                          [Gui.Design.DisplayNameAttribute("Show open")]
                          public bool ShowOpen
                          {
                              get { return showOpen; }
                              set { showOpen = value; }
                          }
                          
                          [Browsable(true)]
                          [Gui.Design.DisplayNameAttribute("Show high")]
                          public bool ShowHigh
                          {
                              get { return showHigh; }
                              set { showHigh = value; }
                          }
                          
                          [Browsable(true)]
                          [Gui.Design.DisplayNameAttribute("Show low")]
                          public bool ShowLow
                          {
                              get { return showLow; }
                              set { showLow = value; }
                          }
                          
                          [Browsable(true)]
                          [Gui.Design.DisplayNameAttribute("Show close")]
                          public bool ShowClose
                          {
                              get { return showClose; }
                              set { showClose = value; }
                          }
                  
                          #endregion
                      }
                  }

                  Comment


                    #10
                    Originally posted by ScottieDog View Post
                    Hi Koganam,

                    Here is the code below... Any help appreciated.

                    I didnīt do it myself, I paid someone to do it and this is what they made of it.. They now decline to fix it.. Maybe he doesnīt know how, heīs certainly not being very friendly about it. I mentioned to him before about the time being 1min off (or the time frame of the chart) and he said "that was normal"...


                    Code:
                     {
                            #region Variables
                     
                            // Wizard generated variables
                            // User defined variables (add any user defined variables below)
                            private DateTime     currentDate     = Cbi.Globals.MinDate;
                            private double        currentOpen        = 0;
                            private double        currentHigh        = 0;
                            private double        currentLow        = 0;
                            private double        currentClose    = 0;
                            private double        priordayOpen    = 0;
                            private double        priordayHigh    = 0;
                            private double        priordayLow        = 0;
                            private double        priordayClose    = 0;
                            private bool        showOpen        = true;
                            private bool        showHigh        = true;
                            private bool        showLow            = true;
                            private bool        showClose        = true;
                            #endregion
                     
                            int dayStart = 800;
                            int dayEnd = 2200;
                            int onDay = 0;
                            /// <summary>
                            /// This method is used to configure the indicator and is called once before any bar data is loaded.
                            /// </summary>
                            protected override void Initialize()
                            {
                                Add(new Plot(Color.Orange, PlotStyle.Hash, "Prior Open"));
                                Add(new Plot(Color.Green, PlotStyle.Hash, "Prior High"));
                                Add(new Plot(Color.Red, PlotStyle.Hash, "Prior Low"));
                                Add(new Plot(Color.Firebrick, PlotStyle.Hash, "Prior Close"));
                     
                                Plots[0].Pen.DashStyle = DashStyle.Dash;
                                Plots[3].Pen.DashStyle = DashStyle.Dash;
                     
                                AutoScale             = false;
                                Overlay                = true;      // Plots the indicator on top of price
                            }
                     
                            protected override void OnStartUp()
                            {
                                if (BarsPeriod.Id == PeriodType.Minute || BarsPeriod.Id == PeriodType.Second) dayStart += BarsPeriod.Value;
                            }
                     
                            /// <summary>
                            /// Called on each bar update event (incoming tick)
                            /// </summary>
                            protected override void OnBarUpdate()
                            {
                                if (Bars == null)
                                    return;
                     
                                if (!Bars.BarsType.IsIntraday)
                                {
                                    DrawTextFixed("error msg", "PriorDayOHLC only works on intraday intervals", TextPosition.BottomRight);
                                    return;
                                }
                     
                     
                                //if (onDay != Time[0].Day)
                                //{
                                //    if (currentOpen != 0)
                                //    {
                                //        priordayOpen = currentOpen;
                                //        priordayHigh = currentHigh;
                                //        priordayLow = currentLow;
                                //        priordayClose = currentClose;
                     
                                //        if (ShowOpen) PriorOpen.Set(priordayOpen);
                                //        if (ShowHigh) PriorHigh.Set(priordayHigh);
                                //        if (ShowLow) PriorLow.Set(priordayLow);
                                //        if (ShowClose) PriorClose.Set(priordayClose);
                                //    }
                     
                                //    onDay = Time[0].Day;
                                //}
                                //else
                                //{
                                //}
                     
                                // If the current data is not the same date as the current bar then its a new session
                                if (currentDate != Bars.GetTradingDayFromLocal(Time[0]) || currentOpen == 0)
                                {
                                    // The current day OHLC values are now the prior days value so set
                                    // them to their respect indicator series for plotting
                                    if (currentOpen != 0)
                                    {
                                        priordayOpen = currentOpen;
                                        priordayHigh = currentHigh;
                                        priordayLow = currentLow;
                                        priordayClose = currentClose;
                     
                                        if (ShowOpen) PriorOpen.Set(priordayOpen);
                                        if (ShowHigh) PriorHigh.Set(priordayHigh);
                                        if (ShowLow) PriorLow.Set(priordayLow);
                                        if (ShowClose) PriorClose.Set(priordayClose);
                                    }
                     
                                    // Initilize the current day settings to the new days data
                                    currentOpen = Open[0];
                                    currentHigh = High[0];
                                    currentLow = Low[0];
                                    currentClose = Close[0];
                     
                                    currentDate = Bars.GetTradingDayFromLocal(Time[0]);
                                }
                                else // The current day is the same day
                                {
                                    if (ToTime(Time[0]) == dayStart * 100) currentOpen = Open[0];
                     
                                    if (ToTime(Time[0]) > dayStart * 100 && ToTime(Time[0]) < dayEnd * 100)
                                    {
                                        // Set the current day OHLC values
                                        currentHigh = Math.Max(currentHigh, High[0]);
                                        currentLow = Math.Min(currentLow, Low[0]);
                                        currentClose = Close[0];
                                    }
                     
                                    if (ShowOpen) PriorOpen.Set(priordayOpen);
                                    if (ShowHigh) PriorHigh.Set(priordayHigh);
                                    if (ShowLow) PriorLow.Set(priordayLow);
                                    if (ShowClose) PriorClose.Set(priordayClose);
                                }
                            }
                     
                            #region Properties
                     
                            [Description("")]
                            [Category("Parameters")]
                            public int DayStart
                            {
                                get { return dayStart; }
                                set { dayStart = Math.Max(0, value); }
                            }
                     
                            [Description("")]
                            [Category("Parameters")]
                            public int DayStop
                            {
                                get { return dayEnd; }
                                set { dayEnd = Math.Max(1, value); }
                            }
                     
                            [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                            [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                            public DataSeries PriorOpen
                            {
                                get { return Values[0]; }
                            }
                     
                            [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                            [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                            public DataSeries PriorHigh
                            {
                                get { return Values[1]; }
                            }
                     
                            [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                            [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                            public DataSeries PriorLow
                            {
                                get { return Values[2]; }
                            }
                     
                            [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                            [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                            public DataSeries PriorClose
                            {
                                get { return Values[3]; }
                            }
                     
                            [Browsable(true)]
                            [Gui.Design.DisplayNameAttribute("Show open")]
                            public bool ShowOpen
                            {
                                get { return showOpen; }
                                set { showOpen = value; }
                            }
                     
                            [Browsable(true)]
                            [Gui.Design.DisplayNameAttribute("Show high")]
                            public bool ShowHigh
                            {
                                get { return showHigh; }
                                set { showHigh = value; }
                            }
                     
                            [Browsable(true)]
                            [Gui.Design.DisplayNameAttribute("Show low")]
                            public bool ShowLow
                            {
                                get { return showLow; }
                                set { showLow = value; }
                            }
                     
                            [Browsable(true)]
                            [Gui.Design.DisplayNameAttribute("Show close")]
                            public bool ShowClose
                            {
                                get { return showClose; }
                                set { showClose = value; }
                            }
                     
                            #endregion
                        }
                    }
                    See additions in blue.

                    Comment


                      #11
                      Thank-you so much Koganam.

                      That is working for CL no problem. But it wonīt work for ES on a 30min chart, it wont plot the line. When I look inside the indicator parameters it has changed the 930 that I input for "960"...... So thatīs throwing it off.

                      On the 6E and GC too thereīs an issue. The start time for these is 0820, it plots the line OK on a 20minute chart, but when I change to 30min chart the line disappears?

                      Thanks for your help so far though. That line of code certainly did the trick for the CL charts on 1, 5 and 30m timeframes.

                      Comment


                        #12
                        Originally posted by ScottieDog View Post
                        Thank-you so much Koganam.

                        That is working for CL no problem. But it wonīt work for ES on a 30min chart, it wont plot the line. When I look inside the indicator parameters it has changed the 930 that I input for "960"...... So thatīs throwing it off.

                        On the 6E and GC too thereīs an issue. The start time for these is 0820, it plots the line OK on a 20minute chart, but when I change to 30min chart the line disappears?

                        Thanks for your help so far though. That line of code certainly did the trick for the CL charts on 1, 5 and 30m timeframes.
                        Ah, the painful vicissitudes of that ToTime() method, and the modulo 60 nature of real time. Let me post something else after I figure how to get around it without rewriting your whole indicator, if it will not take too much time.

                        Comment


                          #13
                          Originally posted by ScottieDog View Post
                          Code:
                           {
                                  #region Variables
                           
                                  // Wizard generated variables
                                  // User defined variables (add any user defined variables below)
                                  private DateTime     currentDate     = Cbi.Globals.MinDate;
                                  private double        currentOpen        = 0;
                                  private double        currentHigh        = 0;
                                  private double        currentLow        = 0;
                                  private double        currentClose    = 0;
                                  private double        priordayOpen    = 0;
                                  private double        priordayHigh    = 0;
                                  private double        priordayLow        = 0;
                                  private double        priordayClose    = 0;
                                  private bool        showOpen        = true;
                                  private bool        showHigh        = true;
                                  private bool        showLow            = true;
                                  private bool        showClose        = true;
                                  #endregion
                           
                                  int dayStart = 800;
                                  int dayEnd = 2200;
                                  int onDay = 0;
                           
                                 int dayStartAdjusted = 0; //Added
                                  /// <summary>
                                  /// This method is used to configure the indicator and is called once before any bar data is loaded.
                                  /// </summary>
                                  protected override void Initialize()
                                  {
                                      Add(new Plot(Color.Orange, PlotStyle.Hash, "Prior Open"));
                                      Add(new Plot(Color.Green, PlotStyle.Hash, "Prior High"));
                                      Add(new Plot(Color.Red, PlotStyle.Hash, "Prior Low"));
                                      Add(new Plot(Color.Firebrick, PlotStyle.Hash, "Prior Close"));
                           
                                      Plots[0].Pen.DashStyle = DashStyle.Dash;
                                      Plots[3].Pen.DashStyle = DashStyle.Dash;
                           
                                      AutoScale             = false;
                                      Overlay                = true;      // Plots the indicator on top of price
                                  }
                           
                          protected override void OnStartUp() //Added
                          {
                          if (BarsPeriod.Id == PeriodType.Minute || BarsPeriod.Id == PeriodType.Second)
                          {
                          int dsTmp = dayStart * 100;
                          int dsTmpHrs = dsTmp / 10000;
                          int dsTmpMins = (dsTmp - dsTmpHrs * 10000) / 100;
                          int dsTmpSecs = dsTmp - dsTmpHrs * 10000 - dsTmpMins * 100;
                          TimeSpan dsTimeSpan = new TimeSpan(dsTmpHrs, dsTmpMins, dsTmpSecs);
                          TimeSpan dsAddTime = new TimeSpan(0, 0, 0);
                          if (BarsPeriod.Id == PeriodType.Minute) dsAddTime = new TimeSpan(0, BarsPeriod.Value, 0);
                          else if (BarsPeriod.Id == PeriodType.Second) dsAddTime = new TimeSpan(0, 0, BarsPeriod.Value);
                           
                          dsTimeSpan = dsTimeSpan.Add(dsAddTime);
                          dayStartAdjusted = ToTime(Time[0].Date.Add(dsTimeSpan));
                          }
                          }
                          // end Additions 
                                  /// <summary>
                                  /// Called on each bar update event (incoming tick)
                                  /// </summary>
                                  protected override void OnBarUpdate()
                                  {
                                      if (Bars == null)
                                          return;
                           
                                      if (!Bars.BarsType.IsIntraday)
                                      {
                                          DrawTextFixed("error msg", "PriorDayOHLC only works on intraday intervals", TextPosition.BottomRight);
                                          return;
                                      }
                           
                           
                                      //if (onDay != Time[0].Day)
                                      //{
                                      //    if (currentOpen != 0)
                                      //    {
                                      //        priordayOpen = currentOpen;
                                      //        priordayHigh = currentHigh;
                                      //        priordayLow = currentLow;
                                      //        priordayClose = currentClose;
                           
                                      //        if (ShowOpen) PriorOpen.Set(priordayOpen);
                                      //        if (ShowHigh) PriorHigh.Set(priordayHigh);
                                      //        if (ShowLow) PriorLow.Set(priordayLow);
                                      //        if (ShowClose) PriorClose.Set(priordayClose);
                                      //    }
                           
                                      //    onDay = Time[0].Day;
                                      //}
                                      //else
                                      //{
                                      //}
                           
                                      // If the current data is not the same date as the current bar then its a new session
                                      if (currentDate != Bars.GetTradingDayFromLocal(Time[0]) || currentOpen == 0)
                                      {
                                          // The current day OHLC values are now the prior days value so set
                                          // them to their respect indicator series for plotting
                                          if (currentOpen != 0)
                                          {
                                              priordayOpen = currentOpen;
                                              priordayHigh = currentHigh;
                                              priordayLow = currentLow;
                                              priordayClose = currentClose;
                           
                                              if (ShowOpen) PriorOpen.Set(priordayOpen);
                                              if (ShowHigh) PriorHigh.Set(priordayHigh);
                                              if (ShowLow) PriorLow.Set(priordayLow);
                                              if (ShowClose) PriorClose.Set(priordayClose);
                                          }
                           
                                          // Initilize the current day settings to the new days data
                                          currentOpen = Open[0];
                                          currentHigh = High[0];
                                          currentLow = Low[0];
                                          currentClose = Close[0];
                           
                                          currentDate = Bars.GetTradingDayFromLocal(Time[0]);
                                      }
                                      else // The current day is the same day
                                      {
                          //          if (ToTime(Time[0]) == dayStart * 100) currentOpen = Open[0];
                          if (ToTime(Time[0]) == dayStartAdjusted) currentOpen = Open[0];
                           
                                          if (ToTime(Time[0]) > dayStart * 100 && ToTime(Time[0]) < dayEnd * 100)
                                          {
                                              // Set the current day OHLC values
                                              currentHigh = Math.Max(currentHigh, High[0]);
                                              currentLow = Math.Min(currentLow, Low[0]);
                                              currentClose = Close[0];
                                          }
                           
                                          if (ShowOpen) PriorOpen.Set(priordayOpen);
                                          if (ShowHigh) PriorHigh.Set(priordayHigh);
                                          if (ShowLow) PriorLow.Set(priordayLow);
                                          if (ShowClose) PriorClose.Set(priordayClose);
                                      }
                                  }
                           
                                  #region Properties
                           
                                  [Description("")]
                                  [Category("Parameters")]
                                  public int DayStart
                                  {
                                      get { return dayStart; }
                                      set { dayStart = Math.Max(0, value); }
                                  }
                           
                                  [Description("")]
                                  [Category("Parameters")]
                                  public int DayStop
                                  {
                                      get { return dayEnd; }
                                      set { dayEnd = Math.Max(1, value); }
                                  }
                           
                                  [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                                  [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                                  public DataSeries PriorOpen
                                  {
                                      get { return Values[0]; }
                                  }
                           
                                  [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                                  [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                                  public DataSeries PriorHigh
                                  {
                                      get { return Values[1]; }
                                  }
                           
                                  [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                                  [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                                  public DataSeries PriorLow
                                  {
                                      get { return Values[2]; }
                                  }
                           
                                  [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                                  [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                                  public DataSeries PriorClose
                                  {
                                      get { return Values[3]; }
                                  }
                           
                                  [Browsable(true)]
                                  [Gui.Design.DisplayNameAttribute("Show open")]
                                  public bool ShowOpen
                                  {
                                      get { return showOpen; }
                                      set { showOpen = value; }
                                  }
                           
                                  [Browsable(true)]
                                  [Gui.Design.DisplayNameAttribute("Show high")]
                                  public bool ShowHigh
                                  {
                                      get { return showHigh; }
                                      set { showHigh = value; }
                                  }
                           
                                  [Browsable(true)]
                                  [Gui.Design.DisplayNameAttribute("Show low")]
                                  public bool ShowLow
                                  {
                                      get { return showLow; }
                                      set { showLow = value; }
                                  }
                           
                                  [Browsable(true)]
                                  [Gui.Design.DisplayNameAttribute("Show close")]
                                  public bool ShowClose
                                  {
                                      get { return showClose; }
                                      set { showClose = value; }
                                  }
                           
                                  #endregion
                              }
                          }
                          Multiple lines added in blue to Variables, OnStartUp() and OnBarUpdate().
                          Last edited by koganam; 04-18-2013, 04:08 AM. Reason: Corrected code.

                          Comment


                            #14
                            Thanks again Koganam, itīs good of you to spend the time helping on this.

                            Unfortuantely I am getting an error when compiling with those last code additions... its throwing an "expected error" regarding line 78, which is this line...

                            Code:
                            if (BarsPeriod.Id == PeriodType.Second) dsAddTime = new TimeSpan(0, 0, BarsPeriod.Value);
                            I can now see this isnīt as easy as I thought it would be.

                            I really thank you for the effort you are putting in - I donīt want to get you into anything time consuming, I realize these things can be a pain.

                            Comment


                              #15
                              Originally posted by ScottieDog View Post
                              Thanks again Koganam, itīs good of you to spend the time helping on this.

                              Unfortuantely I am getting an error when compiling with those last code additions... its throwing an "expected error" regarding line 78, which is this line...

                              Code:
                              if (BarsPeriod.Id == PeriodType.Second) dsAddTime = new TimeSpan(0, 0, BarsPeriod.Value);
                              I can now see this isnīt as easy as I thought it would be.

                              I really thank you for the effort you are putting in - I donīt want to get you into anything time consuming, I realize these things can be a pain.
                              When I looked again at the code, "else if" somehow lost the intervening space and was rendered "elseif". I have corrected the original code.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by pstrusi, Today, 09:06 AM
                              0 responses
                              8 views
                              0 likes
                              Last Post pstrusi
                              by pstrusi
                               
                              Started by vpzdcv, Today, 02:31 AM
                              0 responses
                              11 views
                              0 likes
                              Last Post vpzdcv
                              by vpzdcv
                               
                              Started by YevhenShynkarenko, Today, 01:22 AM
                              1 response
                              20 views
                              0 likes
                              Last Post YevhenShynkarenko  
                              Started by ttodua, Today, 12:52 AM
                              0 responses
                              8 views
                              0 likes
                              Last Post ttodua
                              by ttodua
                               
                              Started by ttodua, Today, 12:50 AM
                              0 responses
                              8 views
                              0 likes
                              Last Post ttodua
                              by ttodua
                               
                              Working...
                              X