Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to know the "MarketPosition" related to a specific strategy

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

    How to know the "MarketPosition" related to a specific strategy

    Hi all,

    Is there a way to know the market position related to a specific strategy.

    I'm using TradeStation to generate trading signals and I didn't found in NT's .dll library any way to do this.

    For example let's assume that I'm trading the eurostoxx futures and I have 2 differents strategies.

    For strategy n°1 a sell order of 2 contracts was executed (I'm short)

    For strategy n°2 a buy order of 3 contracts was executed (I'm long)

    If I use the NTMarketPosition function the output will be : +1

    What am I supposed to do if I only want to know the live position for a specific strategies ? Is there a function like this for example : NTLivePosition(MarketID, StrategyID, AccountID) ?

    Many thanks,

    Sebastien

    #2
    Sebastien,

    Something like this?


    string NTStrategyPosition(string strategyId)
    Gets the position of a strategy. Returns 0 for flat, negative for short and positive for long.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Yes, but in this the theoretical position for the strategy or is this the live position for this strategy ?
      Sometimes there can be discrepancies between the wanted position and the live one that's why I wanted to be sure of that.

      Regards,

      Sebastien

      Comment


        #4
        This would return you the live position the referenced strategy (strategyId) is having.

        Comment


          #5
          Ok great, thank's for your help.

          Sebastien

          Comment


            #6
            Hi all,

            I mentioned before I want to know the live position for each of the strategy that I trade.

            Therefore I've decided to use the NTCommand function to place orders in the market so that I can assigned to each order a specific strategyId and finaly be able to know thanks to the NTStrategyPosition function my live position for each strategy that I trade

            When a trading signal is generated I have a NT's "confirm order placement" box. If I click yes and go to the log table, I have a message telling me that my order is under processing and just after this I have an error message telling that the "strategyId does not exist".

            Where am I supposed to create the strategyId ? in my code ? in NinjaTrader but where ?

            For the moment I do it this way :

            In the top of my TS script :

            AccountID("MyIBAccountNumber")
            SymbolID(Symbol)
            StrategyName("Channel_Breakout")
            PostFix("A")

            If then ....

            Succes = NTCommand("PLACE", AccountID, "SELL", 1, "LIMIT", 2100, 0, "DAY", "", "EnterShort" & "_" & SymbolID & "_" & StrategyName & "_" & PostFix, "", StrategyName & "_" & PostFix);

            According to this, the strategyId should be Channel_Breakout_A, but it seems that I need to create this Id but I don't where.

            Regards,

            Sebastien

            Comment


              #7
              Hi Sebastien, you would need to create the optional strategyID for later reference in your TS code, but I don't think this is the issue at play - you seem to miss the instrument in your NT Place command call, therefore the order in the overload is not correct in the call - http://www.ninjatrader-support.com/H...arameters.html

              Comment


                #8
                Hi Bertrand,

                As you can see in the log details it seems that there is no need in TS to declare the instrument in the NTCommand :

                27/03/2009 12:23:41;ATI;OIF, 'PLACE;U732457;FESXM09;SELL;1;LIMIT;2100;0;DAY;;En terShort_FESXM09_Channel_Breakout_A;;Channel_Break out_A'strategy id 'Channel_Breakout_A'' does not exist;

                27/03/2009 12:23:37;ATI;AT, 'PLACE;U732457;FESXM09;SELL;1;LIMIT;2100;0;DAY;;En terShort_FESXM09_Channel_Breakout_A;;Channel_Break out_A' processing ;

                What's strange is that a the begining of my TS code the StrategyID is declared.

                Variables:
                AccountID("XXXXXX"),
                SymbolID(GetSymbolName),
                StrategyID("Channel_Breakout_A"),

                Comment


                  #9
                  Originally posted by NinjaTrader_Josh View Post
                  string NTStrategyPosition(string strategyId)
                  Gets the position of a strategy. Returns 0 for flat, negative for short and positive for long.
                  Holy batman, that's awesome. I didn't realize that feature existed.

                  Mike

                  Comment


                    #10
                    I tried to make it work by myself but wasn't able to solve the problem.

                    Is there is any TS & NT users that allready ahd this issue ?

                    Is this as something to do with the OIF parameters ? So far I didn't set any specific parameters for this and I'm not sure that I've understood the purpose of this OIF builder.

                    Bertrand, I've checked and it's seems that my error message have nothing to do with a missing Instrument in the NTCommand.

                    Regards,

                    Sebastien

                    Comment


                      #11
                      Sebastien,

                      What code are you using now? The earlier code you have of:

                      Succes = NTCommand("PLACE", AccountID, "SELL", 1, "LIMIT", 2100, 0, "DAY", "", "EnterShort" & "_" & SymbolID & "_" & StrategyName & "_" & PostFix, "", StrategyName & "_" & PostFix);

                      is not related to OIFs. Please clarify as to which exact interface you are using. TradeStation DLL interface or an actual File Interface (OIF)?
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        I've changed the code to make it easier for you to read.

                        I'm using this one but still have an error message :

                        Variables:
                        AccountID("UXXXXXX"),
                        SymbolID(GetSymbolName),
                        StrategyID("Channel_Breakout_A"),

                        If then....

                        Success = NTCommand("PLACE", AccountID, "SELL", 1, "LIMIT", 2100, 0, "DAY", "", "EnterShort" & "_" & SymbolID & "_" & StrategyID , "", StrategyID);

                        For this code I have those logs :

                        27/03/2009 15:06:47;ATI;OIF, 'PLACE;UXXXXXX;FESXM09;SELL;1;LIMIT;2100;0;DAY;;En terShort_FESXM09_Channel_Breakout_A;;Channel_Break out_A' strategy id 'Channel_Breakout_A' does not exist;

                        27/03/2009 15:06:45;ATI;AT, 'PLACE;UXXXXXX;FESXM09;SELL;1;LIMIT;2100;0;DAY;;En terShort_FESXM09_Channel_Breakout_A;;Channel_Break out_A' processing ;

                        Comment


                          #13
                          Hi sebastienb, I noticed from your code that you are not calling an ATM strategy template for management of the order. However this would be needed to work with the strategyID as explained under the PLACE command entry in this link - http://www.ninjatrader-support.com/H...arameters.html

                          Please make sure to define it on the SuperDOM before attempting to call it later in your TS code.

                          Comment


                            #14
                            Guys thanks a lot for your help.

                            Now it works, but I have another question for you. Is there a way to desactivate the ATM Strategy parameters related to targets and stop level. I don't need this fucntionnality as targets and stops orders are managed thanks to TradeStation.

                            Many thanks,

                            Sebastien

                            Comment


                              #15
                              sebastienb,

                              If you leave the ATM's at 0 they won't be used then.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              601 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              347 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              103 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              559 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              558 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X