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

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 inanazsocial, Today, 01:15 AM
          0 responses
          2 views
          0 likes
          Last Post inanazsocial  
          Started by trilliantrader, 04-18-2024, 08:16 AM
          5 responses
          22 views
          0 likes
          Last Post trilliantrader  
          Started by Davidtowleii, Today, 12:15 AM
          0 responses
          3 views
          0 likes
          Last Post Davidtowleii  
          Started by guillembm, Yesterday, 11:25 AM
          2 responses
          9 views
          0 likes
          Last Post guillembm  
          Started by junkone, 04-21-2024, 07:17 AM
          9 responses
          71 views
          0 likes
          Last Post jeronymite  
          Working...
          X