• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Determining when an Instrument has Stopped Trading

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

    Determining when an Instrument has Stopped Trading

    I am trying to find a way to determine if an instrument has stopped trading. One idea I had was to add a second instrument in my code such as ^SP500 which I know will not go away. Then I thought I would find the last bar for ^SP500 using Today(Time[0]) and compare it with the current instrument also using Today(Time[0]) and if they are not equal, I would know the instrument has stopped trading.

    I tied the following code, but it doesn't like the syntax

    if (ToDay(Time[0][0]) < ToDay(Time[1][0]))
    {
    Do something
    }

    Any help would be appreciated.

    #2
    There are potentially a few ways you could approach this.

    The first one that came to mind would be to use OnMarketData() to check for data updates

    http://www.ninjatrader.com/support/h...marketdata.htm

    You could then pair this with a custom timer such as using DateTime.Now and comparing this to to the DateTime.Now of the last OnMarketData update

    http://msdn.microsoft.com/en-us/libr...v=vs.110).aspx

    Let me know if I can further assist.
    LanceNinjaTrader Customer Service

    Comment


      #3
      If I understand what you are proposing, you would use OnMarektData() to find the date of the last change to the data using DateTime.Now. Wouldn't this give a false warning on weekends and market holidays?

      Comment


        #4
        How would you want holidays/weekends to be handled? In the end it would be up to you to decide how long the market needs to be inactive before triggering the condition. It would also require a custom timer event as the default methods in NinjaScript are only called when the market sends data.

        This falls into unsupported territory but if you would like I can try and find an un-supported sample of using a custom timer event.

        What are you trying to have the script do when the market is no longer active?

        Let me know if I can further assist.
        LanceNinjaTrader Customer Service

        Comment


          #5
          I am trying to generate an Alert in a Market Analyzer window when one of the stocks in my list has stopped trading. An example would be LCC which quit trading last week because it merged with another company. If I run a market analyzer screen on the weekend, I wouldn't want to be alerted if the stock has not stopped trading on the exchange. Sorry maybe I wasn't very clear in my original post.

          The reason I wanted to use something like ^SP500 to compare instruments against, was when EOD data is updated ^SP500 would be guaranteed to be updated. So if I can find the Today(Time[0]) of ^SP500 and compare it Today(Time[0]) of my instrument, it is easy to tell if they don't match. But maybe there is a better way. I just don't see it.

          Comment


            #6
            Ok I understand now sorry about that.

            I would think your original approach would work but just needs a minor syntax change from Time to Times

            if (ToDay(Times[0][0]) < ToDay(Times[1][0]))
            {
            //do something
            }

            This would compare the date of the primary series (which ever instrument its applied to) to the secondary series (which I'm assuming you would set to the SP500)

            Let me know if this doesn't resolve your issue.
            LanceNinjaTrader Customer Service

            Comment


              #7
              Thanks. That resolved my issue.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by larkmail, Yesterday, 06:19 PM
              1 response
              4 views
              0 likes
              Last Post NinjaTrader_Marco  
              Started by rexmie888, Yesterday, 09:37 PM
              0 responses
              6 views
              0 likes
              Last Post rexmie888  
              Started by jvanelli, Yesterday, 09:23 PM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_Marco  
              Started by lavalampmj, Yesterday, 06:07 PM
              1 response
              8 views
              0 likes
              Last Post bltdavid  
              Started by Sameer, Yesterday, 04:40 PM
              1 response
              35 views
              0 likes
              Last Post NinjaTrader_EricB  
              Working...
              X