• 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

OnMarketData IB LastClose

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

    OnMarketData IB LastClose

    Hi,

    I have been trying to get the close price for the previous day with OnMarketData, but I never get (e.MarketDataType == MarketDataType.LastClose). My broker is interactive brokers.

    Is this an IB limitation? If yes how can I get the previous day's close? It must be published somewhere since I see a value appearing in the market analyzer under last close....

    Thanks a lot.

    #2
    Unfortunately this is a fundamental data type that IB does not support.

    You could still get the prior close through other methods in OnBarUpdate() such as GetDayBar()
    http://www.ninjatrader.com/support/h...?getdaybar.htm

    Or using Close[] http://www.ninjatrader.com/support/h...html?close.htm

    Please let me know if I can be of further assistance.
    Lance B.NinjaTrader Customer Service

    Comment


      #3
      Well I am using minute bar for multiple instruments. So I guess I could use Close[] but then would have to add a day bar just for that...

      I actually tried the following, but it always return null. Am I supposed to download historical data for the previous day manually?

      Code:
      BarsArray[BarsInProgress].GetDayBar(1)
      Thanks
      Last edited by benoirat; 04-03-2013, 10:12 AM.

      Comment


        #4
        You would have to ensure you're in the correct BIP
        http://www.ninjatrader.com/support/h...inprogress.htm

        If you are then you should be able to use:

        Code:
        // Print the prior trading day's close
        if (Bars.GetDayBar(1) != null)
            Print("The prior trading day's close is: " + Bars.GetDayBar(1).Close.ToString());
        You would need the historical data available on your chart.
        Lance B.NinjaTrader Customer Service

        Comment


          #5
          Ok, so even in this case, I am getting null for evey bar. I currently have 4 minute bars (2 instruments with bid and ask each).

          I am not using a chart, my strategy is running from the strategies tab. Is this an issue? I have days to load parameter set to 2, and minimum bars to zero. I do have the minute data for yesterday, I can see it in the historical data manager and I can simulate over it.

          Comment


            #6
            Could you please post your source file or simplified version that replicates the error?

            I tested this on my end and it seems to work properly when using two instruments on a minute chart

            Code:
            			if (BarsInProgress == 0)
            			{
            				// Print the prior trading day's close
            if (Bars.GetDayBar(1) != null)
                Print("The prior trading day's close is: " + Bars.GetDayBar(1).Close.ToString());
            			}
            			else
            			{
            				// Print the prior trading day's close
            if (Bars.GetDayBar(1) != null)
                Print("The prior trading day's close is: " + Bars.GetDayBar(1).Close.ToString());
            			}
            Lance B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Mr.Trader, Today, 04:11 AM
            0 responses
            4 views
            0 likes
            Last Post Mr.Trader  
            Started by 3lliot, Today, 01:00 AM
            2 responses
            9 views
            0 likes
            Last Post 3lliot
            by 3lliot
             
            Started by JohnSteinberg, Yesterday, 04:19 AM
            0 responses
            22 views
            0 likes
            Last Post JohnSteinberg  
            Started by herben31, Yesterday, 03:00 PM
            0 responses
            28 views
            0 likes
            Last Post herben31  
            Started by ruedigold, Yesterday, 04:53 AM
            2 responses
            13 views
            0 likes
            Last Post sledge
            by sledge
             
            Working...
            X