Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MB Trading does not match IQfeed test?

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

    MB Trading does not match IQfeed test?

    I started my first live trading system running on one machine pointing to MB Trading and I started the same system on my dev box using IQFeed and the SIM account.

    My code is as follows:

    Code:
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] OnBarUpdate() {[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] i = 0; i < CurrentBars.Length; i++) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (CurrentBars[i] <= BarsRequired) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].liveOnly && [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Historical) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (!Historical) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].myAccountSize = GetAccountValue([/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]AccountItem[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].CashValue);[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (BarsInProgress == 0) {[/SIZE]
    [SIZE=2]   Print([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Format([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"OnBarUpdate: {0},{1:C}"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], Time[0].ToShortDateString(), [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].myAccountSize));[/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2]...[/SIZE]
    [SIZE=2]}[/SIZE]
    From the output window At 9:30 AM EST

    My output from the IQFeed connection is what I would expect:
    OnBarUpdate: 3/1/2011,$xx,000.00

    My MT Trading seems to be off by a day
    OnBarUpdate: 2/28/2011,$xx,000.00

    ?
    Thanks,
    Erik

    #2
    I disabled the strategy on the prod machine and set calculate on close to false and I get this:

    OnBarUpdate: 3/2/2011,$xx,000.00
    OnBarUpdate: 3/2/2011,$xx,000.00
    OnBarUpdate: 3/2/2011,$xx,000.00
    OnBarUpdate: 3/2/2011,$xx,000.00
    OnBarUpdate: 3/2/2011,$xx,000.00
    OnBarUpdate: 3/2/2011,$xx,000.00
    OnBarUpdate: 3/2/2011,$xx,000.00
    ...

    Comment


      #3
      Hello,

      Thanks for your note.

      What interval type are you running this on? Daily Bars?

      Also, what session template are you using?

      it also looks like you are using Multi Series. Can you please clarify one what multi series you are adding in.

      I look forward to assisting you further.
      BrettNinjaTrader Product Management

      Comment


        #4
        I am running daily bars multi instrument (AAPL and some ETFs). AAPL is BarsInProgress == 0

        Session Template is only available to select if you used minute bars if use use daily bars that selection goes away, but I do have this code in my Init method:

        Code:
        [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Initialize() {[/SIZE]
        [SIZE=2]TraceOrders = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
        [SIZE=2]TimeInForce = Cbi.[/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]TimeInForce[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Day;[/SIZE]
        [SIZE=2]BarsRequired = ent_LongMAPeriods;[/SIZE]
        [SIZE=2]EntryHandling = [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]EntryHandling[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].UniqueEntries;[/SIZE]
        [SIZE=2]EntriesPerDirection = 1;[/SIZE]
        [SIZE=2]SessionData = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"US Equities RTH"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
        [SIZE=2]CalculateOnBarClose = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
        [SIZE=2]}[/SIZE]

        Comment


          #5
          Hello,

          The session template should not go away when you select daily bars. The session template should still be an option.

          Most likely what may be occuring is this:

          if you have a Default 24/7 session template in use there is a case where the bar reported can get pushed over into the previous day or next day. The reason for this is the provider time stamps there daily bars differently and if a provider time stamps there daily bars around 12:00 midnight. The session template will apply and offset to that time to account for the difference in the exchange time and your local PC time. Therefor moving the time into the next day previous day.

          This does not occur when you use an RTH templte for example.

          Remember- The templates do not effect the formation of the bars. Can only affect the date of the bars in some scenarios.

          Also, please see this note on session templates that is newly added to the help guide, This means that you will need to change the Instruments default session template as well to RTH or ETH so that you are not using Defalt 24/7 which could cause the bars to be a day ahead.

          2. If a multi-series script adds an additional Bars object that already exists on the chart, the script will use the preexisting series instead of creating a new one to conserve memory. This includes that series' session template as applied from the chart. If the Bars object does not exist on the chart, the session template of the added Bars object will be the session template of the primary Bars object. If the primary Bars object is using the "<Use instrument settings>" session template then the additional Bars objects will use the default session templates as defined for their particular instrument in the Instrument Manager.
          BrettNinjaTrader Product Management

          Comment


            #6
            Please look at the code and pictures below and let me know what needs to change or let me know what other info you need I still do not get what is wrong.

            I am setting SessionData in Initialize. Where and what code do I need to add?

            I am running daily bars only (the second picture).

            Thanks,
            Erik

            Code:
            [COLOR=#0000ff]protected[SIZE=2][SIZE=2]override[/SIZE][/SIZE][/COLOR][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Initialize() {[/SIZE]
            [SIZE=2]TraceOrders = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
            [SIZE=2]TimeInForce = Cbi.[/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]TimeInForce[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Day;[/SIZE]
            [SIZE=2]BarsRequired = ent_LongMAPeriods;[/SIZE]
            [SIZE=2]EntryHandling = [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]EntryHandling[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].UniqueEntries;[/SIZE]
            [SIZE=2]EntriesPerDirection = 1;[/SIZE]
            [SIZE=4]SessionData = [COLOR=#a31515][COLOR=#a31515]"US Equities RTH"[/COLOR][/COLOR];[/SIZE]
            [SIZE=2]CalculateOnBarClose = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
            [SIZE=2]}[/SIZE]
            Attached Files

            Comment


              #7
              Hello,

              Can you please let me know what version of NinjaTrader you are using this is located in the Control Center under Help->About and is to the right of the NinjaTrader logo.
              BrettNinjaTrader Product Management

              Comment


                #8
                Hello,

                Also, I got some more information on this. This is expected with Day and strategies. You would not be able to set the session template in Initialize(). Please remove this line, also you need to change the session template in Control Center->Tools->Instrument Manager.

                Pull up all the instruments and then change the session template here to RTH. This should do the trick.

                Let me know if I can be of further assistance.
                BrettNinjaTrader Product Management

                Comment


                  #9
                  I will remove the line of code recompile the strategy, remove the one I have running re add it should I see todays bar?

                  AAPL is set to RTH in instrument editor. It is a new install of NinjaTrader I did not setup the symbol you did???

                  Let me see if removing that line of code makes a difference. Do you think it will even though AAPL was already set to "US Equities RTH"

                  Thanks,
                  Erik
                  Attached Files

                  Comment


                    #10
                    Still no luck

                    I checked AAPL in instrument manager and I checked the first ETF that I add as well and both of them are set to: "US Equities RTH"

                    I removed the line of code from Intialize: SessionData = "US Equities RTH";

                    I removed my active strategy compiled it re added it re enabled it started it and still the last on bar update I see is 2/28/2011 on bar update never got called for 3/1/2011

                    What should I try next? What other info do you need to diagnose the problem.

                    Thanks,
                    Erik

                    Comment


                      #11
                      I am able to reproduce the issue with this strategy:

                      Code:
                      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]namespace[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] NinjaTrader.Strategy {[/COLOR][/SIZE]
                      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]MomentumRotation4[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] : [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Strategy[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] {[/SIZE]
                      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#region[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Variables[/COLOR][/SIZE]
                      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#endregion[/COLOR][/SIZE]
                      [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Initialize() {[/SIZE]
                      [SIZE=2]TraceOrders = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
                      [SIZE=2]BarsRequired = 5;[/SIZE]
                      [SIZE=2]TimeInForce = Cbi.[/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]TimeInForce[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Day;[/SIZE]
                      [SIZE=2]EntryHandling = [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]EntryHandling[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].UniqueEntries;[/SIZE]
                      [SIZE=2]EntriesPerDirection = 1;[/SIZE]
                      [SIZE=2]SessionData = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"US Equities RTH"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
                      [SIZE=2]CalculateOnBarClose = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
                      [SIZE=2]}[/SIZE]
                      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] OnBarUpdate() {[/SIZE]
                      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] i = 0; i < CurrentBars.Length; i++) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (CurrentBars[i] <= BarsRequired) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
                      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (BarsInProgress == 0) {[/SIZE]
                      [SIZE=2]Print([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Format([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"OnBarUpdate: {0}, {1}"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], Time[0], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Historical));[/SIZE]
                      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
                      [SIZE=2]}[/SIZE]
                      [SIZE=2]}[/SIZE]
                      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#region[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Properties[/COLOR][/SIZE]
                      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#endregion[/COLOR][/SIZE]
                      [/COLOR][/SIZE][SIZE=2]}[/SIZE]
                      [SIZE=2]}[/SIZE]
                      prod output (MB Trading):
                      OnBarUpdate: 2/17/2011 2:00:00 PM, True
                      OnBarUpdate: 2/18/2011 2:00:00 PM, True
                      OnBarUpdate: 2/22/2011 2:00:00 PM, True
                      OnBarUpdate: 2/23/2011 2:00:00 PM, True
                      OnBarUpdate: 2/24/2011 2:00:00 PM, True
                      OnBarUpdate: 2/25/2011 2:00:00 PM, True
                      OnBarUpdate: 2/28/2011 2:00:00 PM, True

                      dev output (IQFeed):
                      OnBarUpdate: 2/22/2011 2:00:00 PM, True
                      OnBarUpdate: 2/23/2011 2:00:00 PM, True
                      OnBarUpdate: 2/24/2011 2:00:00 PM, True
                      OnBarUpdate: 2/25/2011 2:00:00 PM, True
                      OnBarUpdate: 2/28/2011 2:00:00 PM, True
                      OnBarUpdate: 3/1/2011 2:00:00 PM, True

                      Comment


                        #12
                        oops forgot to get rid of the line of code in my test strategy let me remove it and try again :-)

                        Comment


                          #13
                          Hello,

                          OK let me know how it goes. If still the same the only thing I can do at this point is run the test on my side if it still gives issue.
                          BrettNinjaTrader Product Management

                          Comment


                            #14
                            I removed that line of code from the test stragety: SessionData = "US Equities RTH";

                            removed the strategies from dev and prod machines recompiled re added strategies and enabled them. I still reproduce the error.

                            Comment


                              #15
                              please see if you can reproduce and let me know. My prod machine is brand new and all I have installed is NinjaTrader and MB Trading. Otherwise it is just running Win 7 64 bit os will all updates from Windows update.

                              Thanks,
                              Erik

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              80 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              46 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              29 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              32 views
                              0 likes
                              Last Post TheRealMorford  
                              Started by Mindset, 02-28-2026, 06:16 AM
                              0 responses
                              66 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Working...
                              X