Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NTMarketposition for IB

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

    NTMarketposition for IB

    I am using Tradestation8 --> IB and wish to check that *IB* does not have a position before I send an order.

    I noticed that the NTMarketposition function uses the TRADESTATION "marketposition" command. That will not return the marketposition for Interactive Brokers !

    Is there a command that I can use to get the IB marketposition.

    Thanks

    #2
    imported post

    The function calls a method on the NT DLL called marketposition and is not to be confused with the EL reserved word "marketposition". NTMarketPosition will return what you are looking for.
    RayNinjaTrader Customer Service

    Comment


      #3
      imported post


      whilst i havent tried it yet im concerned it will not work, because you have used a TS reserved word which the easylanguage compiler recognises.

      for example when i open up the function, the "marketposition" command is highlighted in blue - this means that tradestation has automatically recognised it as a built in TS reserved word.

      Comment


        #4
        imported post

        No, it works fine. Check out e.g. NTSample strategy.

        Comment


          #5
          imported post

          ok thanks.

          Comment


            #6
            imported post

            Dierk
            I had a problem in testing today with NTmarketposition returning zero, for a position that i held in IB.

            it was for "IWM" stock symbol.

            i was using a print statement to verify that NTmarketposition was returning the correct value. it read as:

            print(date,time,NTmarketposition("IWM",""));

            the default account was set to be my live IB account which held the position. i am ASSUMING that the account code can be left blank on this call if you are using the default account.

            the print statement returned the following output:

            1060213.001438.00imktpos=-1 -100.00 0.00

            (the -100 is the TS strategy). the 0.00 is what NTmarketposition returned

            one thing to mention: i am not receiving market data into IB for IWM. however placing orders via the NT ATI works 100% OK if no checks are being made with regards to NTmarketposition.

            can you please let me know if i am doing something wrong or whether perhaps this is a bug in NT ATI

            thanks

            Comment


              #7
              imported post

              apologies, i had the wrong piece of code pasted for that routine. it should have been:
              .............
              NTContracts=NTmarketposition(NTProductCode,"");

              print(date,time,"imktpos=-1 ",TSContracts,NTContracts);

              {please note that NTProductCode = "IWM"}

              Comment


                #8
                imported post

                Jonno,

                NTMarketPosition does not take the stock symbol as an argument. Not sure if this is causing the issue.

                print(NTMarketPosition(""));

                should print out the correct position for the instrument loaded in the TS chart that your strategy is applied to.

                Ray

                PS - Forgot to add that you are correct in your understanding of the default account use.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  imported post

                  Ray
                  ray you are right, i had actually changed the P1 parameter in the NTmarketposition function/DLL to be passed in as a string as opposed to the chart based TS EL symbol retrieve that was being done. sorry i also forgot to mention that! no more surprises i promise. :-)

                  can i request an enhancement that the NTmarketposition function allows you to explicitly pass the product code?

                  I am trying to do symbol substitution, where when i get a signal on the russell via an applied strategy, i am sending orders for IWM. part of this *requires* position checks on IWM which does not seem possible from the ER2 chart.

                  i would think that plenty of users will find it useful to be able to pass the product code to the NTmarketposition function call as opposed to hard coded symbol retrieve.

                  thanks
                  angus

                  Comment


                    #10
                    imported post

                    Angus,

                    Thanks for your suggestion. Will add to list for consideration.

                    Ray
                    RayNinjaTrader Customer Service

                    Comment


                      #11
                      imported post

                      Actually, the underlying DLL function is implemented with symbol/account name. Its just the NTMarketPosition wrapper function that handles it for convenience.

                      Open up the NTMarketPosition function in EL and create a new one that takes the symbol name as an input.

                      Ray
                      RayNinjaTrader Customer Service

                      Comment


                        #12
                        imported post

                        i tried that id did not work. appreciate if u can look at this and let me know if i have done something wrong. if not, can u pls let me know when it will be fixed? i am having to resort to TradeBolt in the meantime.

                        here is the modified wrapper:

                        { ** Copyright (c) 2005, NinjaTrader LLC [email protected] }
                        DefineDLLFunc: "NtDirect.dll", int, "MarketPosition", lpstr, lpstr;
                        inputs: Account(string),ProductCode(string);

                        NTMarketPosition = MarketPosition(ProductCode, Account);

                        -------------------------------------------------------------------------------------------------------

                        here is a little test indicator that i applied to a chart:

                        value1 = NTMarketPosition("IWM",""); {def acct = live account in NT options setup}
                        { it also does not work if i explicitly define my
                        account number as parameter 2 string}
                        print(date,time,symbol," ",value1);

                        ---------------------------------------------------------------------------------------------------------

                        here is the print output:

                        1060224.001300.00IB:KSH6 0.00 <=== you can see that it is not picking up the IB position that currently exists in my live account
                        1060224.001300.00IB:KSH6 0.00
                        1060224.001300.00IB:KSH6 0.00

                        ----------------------------------------------------------------------------------------------------------

                        Comment


                          #13
                          imported post

                          Is Automated Trading Enabled via the File--> menu?
                          RayNinjaTrader Customer Service

                          Comment


                            #14
                            imported post

                            yes

                            Comment


                              #15
                              imported post

                              The MarketPosition function will only return information for positions created through the ATI. The ATI does write all position information to a files (See the file interface section) indpendant if they were created through the ATI or not. This might be an alternate approach.

                              Ray
                              RayNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by AaronKoRn, Today, 09:49 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post AaronKoRn  
                              Started by carnitron, Today, 08:42 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post carnitron  
                              Started by strategist007, Today, 07:51 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post strategist007  
                              Started by StockTrader88, 03-06-2021, 08:58 AM
                              44 responses
                              3,975 views
                              3 likes
                              Last Post jhudas88  
                              Started by rbeckmann05, Today, 06:48 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post rbeckmann05  
                              Working...
                              X