Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Why NTMarketPosition doesn't work?

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

    Why NTMarketPosition doesn't work?

    I use the DLL functions in EasyLanguage to place automatic orders from TS2000i to NT with GAIN simulated account, and I noticed that NTMarketposition("") does not work, that is no matter what happens it always returns 0. I must say that all orders are submitted via TS i.e. automatically. This was also confirmed via debugging and printing values to separate file using print function in EL.
    If one uses statement such as if NTMarketposition("")=1 then begin it won't work, even though NTBuyMarket was successfully submitted previously.
    I must mention that i also tried using
    If NTMarketposition("Sim101")=1 then begin but with no avail.

    #2
    Please use the latest NT 6.5 Beta (available in this support forum) as there have been changes to NTMarketPosition() underlying function. Please let us know if it does not work as you expect.
    RayNinjaTrader Customer Service

    Comment


      #3
      Nope, it still does not work as it suppose to.

      Comment


        #4
        Can you try it by specifiying the account name.

        Print(NTMarketPosition("Sim101"))

        etc...
        RayNinjaTrader Customer Service

        Comment


          #5
          I am seeing the same thing in ver 6.0.1000.8. I always get back a value of zero reguardless of how I call the function.

          Comment


            #6
            NT6: You only will see something if you entered the position in the very session you are in.
            NT6.5: You even would see something if this position was entered in any session.

            -> I suggest updating to latest NT6.5 and trying again: http://www.ninjatrader-support.com/v...ead.php?t=4944

            Comment


              #7
              I am seeing this bad behavior in the same session.

              I place an order, see it accepted, see it filled, and then I get back zero when calling NTMarketPosition when called with either the account or an empty string.

              I am printing this all out in TS as it unfolds over a short interval.

              Comment


                #8
                Thanks for feedback. I recommend updating to NT6.5 and trying again.

                Comment


                  #9
                  I installed 6.5, and it performs in the exact same fashion.

                  Comment


                    #10
                    Then there is no position for this instrument in NT.

                    What's the exact name of your TS instrument?

                    Comment


                      #11
                      Are you kidding me?

                      If an order is filled and position is showing up in DOM and it is in the log and it is in everything else in NT, then there is a position.

                      I am trying to trade the ER2. This is done with the ER2.D symbol in TS, and Instrument "ER2 03-08" in NT.

                      I use this same setup to successfully enter trades in "live" mode, so I know the instruments etc are not an issue.

                      The issue I am having is I am trying to use NTMarketPosition for the first time because I am extended a strategy to issue more than one order per day (working strategy only issues a single order per day). I want to block all new orders until the position returns to flat. Everything that I have tried always returns zero from the function call.

                      Comment


                        #12
                        TS instrument names with suffix like ".D" do not work as expected. You might want to try ER2 with expiry or the continuous contract.

                        Comment


                          #13
                          That was it.

                          Changing from @er2.d to @er2 in TS caused the NTMarketPosition to start working.

                          This should be fixed as it is a bug in the symbol name mapping (those two symbols should work the same as they should both be mapped to ER2 front month). Is it easy enough to remove any ".D" postfix before mapping?

                          This is kind of painful, as I require the ".D" contract for my study.

                          Thanks for helping figure this out.

                          Comment


                            #14
                            Thanks for your suggestion. We'll add it to the list of future considerations.

                            Comment


                              #15
                              If you change the NTMarketPosition EL code to the code below it will function correctly even on ".D" based symbols (works for me on the @ER2.D). The code change basically looks for a ".D" postfix and removes it if present before calling MarketPosition.

                              DefineDLLFunc: "NtDirect.dll", int, "MarketPosition", lpstr, lpstr;
                              inputs: Account(string);
                              vars: vSymbol(GetSymbolName);
                              if RightStr(vSymbol, 2) = ".D" then vSymbol = LeftStr(vSymbol, StrLen(vSymbol)-2);
                              NTMarketPosition = MarketPosition(vSymbol, Account);

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by GussJ, 03-04-2020, 03:11 PM
                              11 responses
                              3,221 views
                              0 likes
                              Last Post xiinteractive  
                              Started by andrewtrades, Today, 04:57 PM
                              1 response
                              10 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by chbruno, Today, 04:10 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post chbruno
                              by chbruno
                               
                              Started by josh18955, 03-25-2023, 11:16 AM
                              6 responses
                              437 views
                              0 likes
                              Last Post Delerium  
                              Started by FAQtrader, Today, 03:35 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post FAQtrader  
                              Working...
                              X