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

Simple problem accessing Closing time of a bar?

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

    Simple problem accessing Closing time of a bar?

    Howdy,

    I am not a complete newb with scripting, and have a small amount of experience with NT scripts.

    There is something that is having me vexed, as I am pretty sure I have accessed time of a bar many times like this in the past?

    I am simply trying to get the closing time of the bar, using the "Time[0]" DateTime object. Here is a simplified version of what I have, using output commands just for debugging purposes.

    Code:
    Print(Time[0] +",  " +Close[0] +",  " + dayPole);
    The Close is just there to check what it is actually plotting. "dayPole" is just a DateTime that I want to do other things with later. Ignore that for now.

    A sample of the output window is attached in the picture. You can see instead of plotting the actual time of the bar, it is just giving me the closing price, instead of the time. Am I missing something here?
    Attached Files

    #2
    Try this:

    Time[0].ToString()

    Comment


      #3
      Originally posted by BigWaveDave View Post
      Try this:

      Time[0].ToString()
      Thanks, I tried that earlier to no avail as well, still for some reason is plotting the Close of the bar

      This is really weird, as I'm checking some of my other scripts I've written in the past, and referencing time of a bar in the seem way seems to work fine?

      I've also checked my declarations block to be sure nothing is funky there as well, and it looks just like all my other scripts.

      Nothing weird pops up in the log either. I wonder if I could have some type of corruption somewhere?

      I've also tried what I think would be the obvious things like restarting NT, removing and re-adding my indie.

      Attaching the script just in case anyone can run it to be sure it won't reference time somewhere else as well.

      Thanks,
      Forrest
      Attached Files
      Last edited by forrestang; 02-13-2013, 06:54 PM.

      Comment


        #4
        Uh, looks you have a conflict with the naming of this property... I think.
        Call it something other than Time.


        #region Properties
        [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 Time
        {
        get { return Values[0]; }
        }
        #endregion

        Comment


          #5
          Originally posted by BigWaveDave View Post
          Uh, looks you have a conflict with the naming of this property... I think.
          Call it something other than Time.


          #region Properties
          [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 Time
          {
          get { return Values[0]; }
          }
          #endregion
          Surely a second set of eyes helps! That was a dumb name to give that property. I would have probably never caught that. Thank you sir for taking the time! Much appreciated!

          Forrest

          Comment


            #6
            I could see that one causing no end of aggravation, especially if you want to do more with Time[0] than just print it out... lol.

            To be honest.. I'm surprised it compiled.

            cheers.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CortexZenUSA, Today, 12:53 AM
            0 responses
            1 view
            0 likes
            Last Post CortexZenUSA  
            Started by CortexZenUSA, Today, 12:46 AM
            0 responses
            1 view
            0 likes
            Last Post CortexZenUSA  
            Started by usazencortex, Today, 12:43 AM
            0 responses
            5 views
            0 likes
            Last Post usazencortex  
            Started by sidlercom80, 10-28-2023, 08:49 AM
            168 responses
            2,265 views
            0 likes
            Last Post sidlercom80  
            Started by Barry Milan, Yesterday, 10:35 PM
            3 responses
            12 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X