Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Checking if Today == EntryDate

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

    Checking if Today == EntryDate

    I need a programmatic way to check if..

    Today() == EntryDate()

    This seems like a way. Is there an easier way?

    Code:
    ToDay(Times[6][0]) == ToDay( Times[6] [ BarsSinceEntry() ] )
    Thanks

    #2
    Originally posted by borland View Post
    I need a programmatic way to check if..

    Today() == EntryDate()

    This seems like a way. Is there an easier way?

    Code:
    ToDay(Times[6][0]) == ToDay( Times[6] [ BarsSinceEntry() ] )
    Thanks
    Your question is a bit ambiguous. How exactly do you mean?

    Are you trying to find out if the CurrentBar time is the same as the trade entry time, or are you trying to determine if the actual current trading day is the same as the trade entry time? (In the latter case, any weekend day will always return false).

    Comment


      #3
      Current bar date. The exit trade logic needs to adjust for if the trade was entered on the same day.

      Thanks for the reply.

      Comment


        #4
        Originally posted by borland View Post
        Current bar date. The exit trade logic needs to adjust for if the trade was entered on the same day.

        Thanks for the reply.
        You are better off using DateTime objects then.

        First you must capture the entry time into a variable. Let us call it TradeEntryTime, which has to be a class DateTime variable.

        To compare the dates, simply compare them.
        Code:
        if (TradeEntryTime.Date == Time[0].Date)
        {
        //act as necessary
        }

        Comment


          #5
          Hello borland,

          koganam provides a great way to compare the time of when your entry occurred to the time of the bar your strategy is currently evaluating.

          To add on to koganam's post, you can use OnExecution() to obtain that entry time.

          Code:
          // assuming our entry has a signal name of "Entry"
          protected override void OnExecution(IExecution e)
          {
               if (e.Order != null && e.Order.Name == "Entry" && e.Order.OrderState == OrderState.Filled)
                    TradeEntryTime = e.Time;
          }
          Zachary G.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          574 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          332 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          553 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X