Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DateTime Comparisons

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

    DateTime Comparisons

    I am trying to debug a script. I want to check a specific bar on the strategy tester.
    I will need the info for a specific date/time... see the red highlight below.
    I cannot find this in the ref section.

    protectedoverridevoid OnBarUpdate()
    {
    SMACurrent=SMA(BarsArray[
    0],50)[0];
    SMAPast=SMA(BarsArray[
    0],50)[1];

    //if SMACurrent>SMAPast consider this an up trend
    if (SMACurrent > SMAPast) <<<< and DateTime of a bar = '8/15/2012 5:00:00 AM
    {

    objBarsAgoNumber.Set (Closes[
    0][1]);
    BarsAgoNumber = (HighestBar (objBarsAgoNumber,
    30)+1);
    HighValuePast=MAX(High,
    30)[1];
    HighValueCurrent=Closes[
    0][0];
    Thank you,
    Duke

    #2
    Is this what you're looking for?

    DateTime thatOneTime = new DateTime(2012, 8, 15, 5, 0, 0);
    if (SMACurrent > SMAPast && Time[0] == thatOneTime)
    {...}

    Comment


      #3
      Duke,

      You can obtain this information just by calling Time[0].

      You'd wanna put this below your condition.

      Code:
      if (SMACurrent > SMAPast) <<<< and DateTime of a bar = '8/15/2012 5:00:00 AM
      {
      Print(Time[0]);
      }
      MatthewNinjaTrader Product Management

      Comment


        #4
        Thank you... It is exactly what I was looking for.
        Duke

        Comment


          #5
          I need to process a certain bar at a given time. It needs to be a condition of getting thru the 'if' statement.
          Thanks, Matthew...

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          181 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Started by CaptainJack, 04-24-2026, 11:07 PM
          0 responses
          334 views
          0 likes
          Last Post CaptainJack  
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          258 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          358 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          187 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Working...
          X