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 CarlTrading, 03-31-2026, 09:41 PM
          1 response
          152 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          89 views
          1 like
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          133 views
          2 likes
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          127 views
          1 like
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          107 views
          0 likes
          Last Post CarlTrading  
          Working...
          X