Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

What is the beset way to find the most recent date the market was open?

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

    What is the beset way to find the most recent date the market was open?

    Examples:
    • I run it in the evening, and the market was open that day, I expect that date
    • I run it during the day and the market is open then I expect that date
    • I run it any time the market is not open I expect the last date the market was open

    Is there any reasonably elegant way to do that?


    Thanks,
    EV

    #2
    Hello,

    Thanks for your post.

    The easist way to find the time of the last bar from an indicator is to use Time[0]. This will be the time of the last bar.

    For example:
    Print(Time[0]);

    This would print the close time of the last bar in the Output Window.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello,

      Thanks for your post.

      The easist way to find the time of the last bar from an indicator is to use Time[0]. This will be the time of the last bar.

      For example:
      Print(Time[0]);

      This would print the close time of the last bar in the Output Window.
      Thanks for the idea, but it is not quite what I need. II am trying to identify securities that did NOT trade the last trading day. Unless you have a better idea, what I need is to compare the time of the last bar to the last trading day, so I can flag mis-matches.

      --EV

      Comment


        #4
        Hi ETFVoyageur,
        Originally posted by ETFVoyageur View Post
        what I need is to compare the time of the last bar to the last trading day, so I can flag mis-matches.

        --EV
        That would work fine.

        You may need to use the current bar's time and subtract a day (and use just the date not the time after this), and use the current time and subtract a day (and use just the date) for a good comparison.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I'm still not with you. Suppose the date of the last daily bar is not today. How do I know whether the discrepancy is due to the market not being open, or to the security not trading?

          --EV

          Comment


            #6
            Hi ETFVoyageur,

            You have the right idea of comparing the bar date to the date of the last session.

            I am just thinking that you would need to do a little bit of work for that to work correctly.

            I mentioned that you should use the current time and subtract a day. Really you will need to have the days that the instrument trades hard coded into the strategy to know if the previous day was a trading day.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              Hi ETFVoyageur,

              You have the right idea of comparing the bar date to the date of the last session.

              I am just thinking that you would need to do a little bit of work for that to work correctly.

              I mentioned that you should use the current time and subtract a day. Really you will need to have the days that the instrument trades hard coded into the strategy to know if the previous day was a trading day.
              And that is what I am asking for -- how to determine the last trading session, whether it is today or some other day. I do not want to hard code it, because things change. Furthermore, any hard coding I do will not know anything about market holidays. There really needs to be a supported way to know when the market was open. Getting it right is too complex to be hard-coded into an indicator.

              I suppose I could load a data series for something I know traded, such as SPY or an index and look at its last date. Not very elegant, and pretty darned heavyweight if I do it in places like Market Analyzers with 1600-2500 rows.

              --EV

              Comment


                #8
                To bring some closure to this thread, here is what I have done. It is a hack, and not mathematically satisfying. However, it also seems to be adequate for now. I wrote a simple custom indicator, specifically for Market Analyzer use, that does the following:
                • It checks whether the date/time of the last bar is within the last 7 days. I'm not interested in anything that has not traded in the last week anyway. In practice, this seems pretty good at getting rid of the chaff.
                • If so, it returns the closing price
                • If not, it returns -1

                You can then filter on:
                • <= 0 to hide stocks not actually trading
                • Any price you like to hide stocks that are not in the price range you like to trade

                As I said, it is a hack. It would be better to compare to the last open market date instead of 7 days, but I now of no sensible way to do that. (I consider something like using a SPY data series and looking at the last date to be too heavyweight for big Market Analyzers.)

                As far as I can see, this meets my needs for now. Any better ideas are always welcome, so speak up if you have a better idea.

                --EV

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                571 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                330 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
                548 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                549 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X