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()


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

    Please let me know if I can be of further assistance.
    LanceNinjaTrader 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, 11:12 AM.

      Comment


        #4
        You would have to ensure you're in the correct BIP


        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.
        LanceNinjaTrader 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());
            			}
            LanceNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by gentlebenthebear, Today, 01:30 AM
            2 responses
            13 views
            0 likes
            Last Post gentlebenthebear  
            Started by Kaledus, Today, 01:29 PM
            2 responses
            8 views
            0 likes
            Last Post Kaledus
            by Kaledus
             
            Started by frankthearm, Yesterday, 09:08 AM
            13 responses
            45 views
            0 likes
            Last Post frankthearm  
            Started by PaulMohn, Today, 12:36 PM
            2 responses
            16 views
            0 likes
            Last Post PaulMohn  
            Started by Conceptzx, 10-11-2022, 06:38 AM
            2 responses
            56 views
            0 likes
            Last Post PhillT
            by PhillT
             
            Working...
            X