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 yertle, Today, 08:38 AM
            0 responses
            4 views
            0 likes
            Last Post yertle
            by yertle
             
            Started by Mestor, 03-10-2023, 01:50 AM
            15 responses
            378 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by samish18, Yesterday, 08:57 AM
            10 responses
            27 views
            0 likes
            Last Post samish18  
            Started by matty89, 03-02-2020, 08:31 AM
            34 responses
            3,039 views
            1 like
            Last Post NinjaTrader_BrandonH  
            Started by kujista, Today, 05:44 AM
            3 responses
            14 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X