Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Incorrect Opening Price

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

    Incorrect Opening Price

    I've been running in simulated mode connected to interactive brokers and I've been consistently getting what appears to be incorrect prices for the open. I've seen incorrect prices when connecting to esignal as well for data feeds. With IB it's a few cents but with esignal it has been far more severe at times. I understand that the first bar is the closing bar of the previous day, so I discard it.

    When I backtest the same strategy, the opening bar price is accurate. It's only during simulated real-time testing that is incorrect. In order to get the open of the first bar I have been using this piece of code.

    CurrentDayOHL().CurrentOpen[Bars.BarsSinceSession];

    Am I doing something wrong?

    Thanks for any help

    #2
    IZ_Trader, welcome to our support forums! Are you perhaps connected to a simulated feed with delay as for example true for the IB demo account?

    To access the current day's open price this snippet should do it -

    Code:
     
    double currentOpenValue = CurrentDayOHL().CurrentOpen[0];
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply. I'm excited to get involved.

      You may be correct on the delay for the feed for IB. I think there is a 5 second delay. That would explain the discrepency.

      I can't figure out why esignal is giving me such disparate numbers though. For example at the open for today (7/14/09) I'm getting 53.41 as the opening price for FAZ. Not sure where that number is coming from.

      Regarding the code snippet

      double currentOpenValue = CurrentDayOHL().CurrentOpen[0];

      isn't that the same as Open[0]? at any bar in the session I'm trying to check the open of the whole day. Will that code snippet give me that?

      Thanks!

      Comment


        #4
        This would depend on which chart interval you're trying this, Open[0] would refer to the last candle, whereas my snipped would give you the day's open level - please also check into which session times you entered in your Chart Properties (doubleclick on the chart to access those settings).
        BertrandNinjaTrader Customer Service

        Comment


          #5
          it looks like that code snippet did the trick for esignal as the data feed.

          As for using IB as a data feed it looks like you need to make sure to check the box that included historical data for that account connection and the entrance prices now look good.

          Thanks for your help!

          Comment


            #6
            I spoke to soon, this is still plagueing me. It seems that even with esginal as my data feed that I am getting incorrect opening prices using this code snippet

            double currentOpenValue = CurrentDayOHL().CurrentOpen[0];

            when I restart the strategy after the instrument has opened then I get the correct opening prices. Any ideas why this would be happening. There shouldn't be any feed delay with esginal.

            Thanks

            Comment


              #7
              You will need to check the time of when you are actually printing this value and making sure you are doing so at the correct time.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                I am outputting the Day, Hour and Minute to the log in order to help debug this.

                Regardless, I am trying to retrieve the opening price for the DAY at the close of each minute bar, not the open of that specific bar.

                Shouldn't this value be the same from the opening bar forward using this code snippet?

                double currentOpenValue = CurrentDayOHL().CurrentOpen[0];

                Again, if I start the strategy after the open I retrieve the correct opening price.

                Thanks

                Comment


                  #9
                  IZ Trader,

                  I guess I am not following you. Can you please provide a complete code snippet of what you have for the prints and then provide me with the sequence of events or just the output of your prints.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    This is what I have in onbarupdate

                    protectedoverridevoid OnBarUpdate()
                    {
                    if (Historical)
                    return;

                    Log("Time: Hour: "+ Time[0].Hour.ToString() + " Minute: " + Time[0].Minute.ToString() , NinjaTrader.Cbi.LogLevel.Information);

                    Log(
                    "Time: Day "+ Time[0].Day.ToString() + " System Day: " + System.DateTime.Today.Day.ToString() , NinjaTrader.Cbi.LogLevel.Information);
                    //
                    if(Time[0].Day != System.DateTime.Today.Day)
                    return;


                    if (BarsInProgress == 0) //FAS
                    {
                    Log(
                    "Instrument 1 - OHLC : "+ Time[0].ToString() + " " + Open[0].ToString() + " " + High[0].ToString() + " " + Low[0].ToString() + " " + Close[0].ToString() , NinjaTrader.Cbi.LogLevel.Information);

                    Instr1Open = CurrentDayOHL().CurrentOpen[
                    0];

                    Log("Instrument 1 Open: " + Instr1Open.ToString(), NinjaTrader.Cbi.LogLevel.Information);

                    ...

                    At this point I execute a trade depending on the opening price of the day and the current bar.

                    Comment


                      #11
                      Continuing.. as post was over 10000 characters.

                      Below is the output of the second bar for this morning
                      7/27/2009 6:31:59 AM Default Instrument 1 Open: 51.49
                      7/27/2009 6:31:59 AM Default Instrument 1 - OHLC : 7/27/2009 6:32:00 AM 51.47 51.49 51.22 51.33
                      7/27/2009 6:31:59 AM Default Time: Day 27 System Day: 27
                      7/27/2009 6:31:59 AM Default Time: Hour: 6 Minute: 32

                      This is for the instrument "FAS" whose opening price should be 51.53

                      Let me know if you need any additional code. I tried to include all the relevant parts.

                      Thanks

                      Comment


                        #12
                        And how are you determining the price is 51.53? No where in any of your data are you seeing 51.53. When working with indicators everything is based off of what is on the chart. Please mouse over your chart with the Data Box open to view prices. Remember using CurrentDayOHL will get you values based on your session breaks and not actual dates. Please check the prices at the spot of a session break.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          I'm actually comparing it to the opening price when I just open up esignal.
                          If I shut down my strategy and then start it up again, I get the correct opening prices. i did this at around 8:34 this morning

                          7/27/2009 8:34:00 Default Instrument 1 Open: 51.53
                          7/27/2009 8:34:00 Default Instrument 1 - OHLC : 7/27/2009 8:34:00 AM 53.44 53.5 53.43 53.45
                          7/27/2009 8:34:00 Default Time: Day 27 System Day: 27
                          7/27/2009 8:34:00 Default Time: Hour: 8 Minute: 34

                          Comment


                            #14
                            Not following. Please post a screenshot. It will give you the data as seen on the chart and nothing else.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              In fact, why don't you just throw on the CurrentDayOHL indicator onto the chart to see what values you should be getting.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by FrazMann, Today, 11:21 AM
                              2 responses
                              6 views
                              0 likes
                              Last Post NinjaTrader_ChristopherJ  
                              Started by rjbtrade1, 11-30-2023, 04:38 PM
                              2 responses
                              80 views
                              0 likes
                              Last Post DavidHP
                              by DavidHP
                               
                              Started by Spiderbird, Today, 12:15 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_ChristopherJ  
                              Started by lorem, Yesterday, 09:18 AM
                              5 responses
                              18 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by cmtjoancolmenero, Yesterday, 03:58 PM
                              12 responses
                              42 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X