Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using int.MaxValue for ExitLong() Quantity Param.

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

    Using int.MaxValue for ExitLong() Quantity Param.

    Hello,

    I like using ExitLong(...) method overloads without a quantity so that the NT8 execution engine knows to exit either my entire position, or my entire position that was entered with an entry order having a certain signal name, regardless of the number of entry orders and their signal names, and regardless of the number of exit orders already executed as part of my scaling out logic.

    The problem is that the only ExitLong(...) method overload that accepts a parameter for "barsInProgressIndex" also requires that "quantity" be provided as well.

    The list of ExitLong method overloads is displayed on this page: https://ninjatrader.com/support/help...s/exitlong.htm

    Here is the only ExitLong method overload that accepts "barsInProgressIndex":
    ExitLong(int barsInProgressIndex, int quantity, string signalName, string fromEntrySignal)

    Is it safe, and is it the best possible solution, to pass a value of int.MaxValue as the value for the "quantity" parameter into this method overload in order to safely exit out of either 1) an entire position or 2) the entire position whose entry order had a specific signal name, as the following two method calls demonstrate?

    // Flatten only the part of the position whose entry order had a signal name of "SignalNumber8", for the instrument whose "barsInProgressIndex" is 1.
    ExitLong(1, int.MaxValue, "ExitSignal14", "SignalNumber8");

    // Flatten the entire position for the instrument whose "barsInProgressIndex" is 1, by using "" for the entry signal name.
    ExitLong(1, int.MaxValue, "ExitSignal14", "");

    Thank you for your help,

    EquityTrader

    #2
    Hello EquityTrader,

    Under the managed approach, NinjaTrader would only submit an exit call for what your position was. So by entering quantity as Int.MaxValue, you are submitting an exit call it with an order quantity of 2,147,483,647, it would be expected that your full position would be closed.

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      NinjaTrader_AlanP,

      Thanks a lot for the information.

      It sounds like you are saying that using int.MaxValue for the Quantity for any managed exit order is a safe and acceptable way to exit an entire position, either for a particular entry signal name or for all entry signal names for a given instrument. If this is true, it is great news!

      If the conclusion I have drawn from NinjaTrader_AlanP's answer is incorrect or needs to be qualified with caviats, could somebody please respond to this forum thread with their corrections?

      Thanks again!

      EquityTrader

      Comment


        #4
        Hello EquityTrader,

        It is recommended you pass the position quantity to your exit call and not use int.MaxValue.

        You should consider saving your position to a variable and passing this variable to your exit call and not rely on int.MaxValue.

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Hello NinjaTrader_AlanP,

          That is unfortunate, for the following reason:

          The managed order exit methods that don't have a barsInProgressIndex parameter already have method overloads without a quantity parameter. This fantastic feature makes it very easy to safely exit an entire position, either for a particular entry signal name or for all entry signal names for a given instrument, so long as the instrument being exited has the same BarsInProgress value as the current value for BarsInProgress.

          Unfortunately, the NinjaScript API currently lacks managed order exit method overloads that include a barsInProgressIndex parameter but don't have a quantity parameter, and you've said that I should not use int.MaxValue for the quantity.

          It will be difficult to constantly store and update variables for all of the positions for all of the unique entry signals that currently have positions on, as I am scaling in and scaling out constantly.

          I feel that I am stuck, unless you can help me think of a way out of my dilemma.

          I need a safe way to fully exit out of a managed position (either for a particular entry signal name or for all entry signal names for a given instrument) for a symbol whose BarsInProgress value is different than the current value for BarsInProgress,
          as in the example of making trading decisions based on a primary instrument of SPY but trading a secondary instrument of GLD.

          How can I do this without being forced to constantly store and update variables for all of the positions for all of the unique entry signals that currently have positions on?

          Could the NinjaScript development team either add these missing method overloads, or could you post about what the current quantity-less method overloads pass to the private core order submission methods to tell the platform to "exit out of the entire position"? (I was guessing that the value was int.MaxValue, but maybe I am wrong).

          Thanks for your patience in dealing with my questions. Hopefully my question can be seen as a way to make the NinjaScript API better in a way that benefits everybody.

          Thanks again,

          EquityTrader

          Comment


            #6
            Hello Equity Trader,

            I will submit a feature request that they’re be a syntax which allows you to specify a BIP but not quantity.

            The recommended way to exit unique entry signals would be to store the position of those entries to a variable and pass that to your exit call.

            Please let us know if you need further assistance.
            Alan P.NinjaTrader Customer Service

            Comment


              #7
              Hello NinjaTrader_AlanP,

              Thank you very much for submitting that feature request.

              It will really complete the NinjaScript Order Submission API
              , and will encourage algorithmic trading across multiple instruments on your platform. Some platforms can't do this at all anyway, but by adding in these method overloads, NinjaTrader will really stand out to multi-instrument traders as being a good choice for everything from basic statistical arbitrage to more complicated strategies.

              Currently, based on your recommendations, I can see that there is really no good way for me to do what I want to do with NinjaTrader, since passing int.MaxValue for Quantity is not recommended.

              Thanks again for submitting the feature request. I will check back periodically to see if NinjaTrader can do what I need in this regard. Hopefully it is an easy enough change, since NinjaScript already has the quantity-less overloads for its exit order methods that (unfortunately) lack a barsInProgressIndex.

              EquityTrader

              Comment


                #8
                Hello EquityTrader,

                The feature request has been assigned SFT-2612 and votes are being tracked.

                Please let us know if you need further assistance.
                Alan P.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks, NinjaTrader_AlanP!

                  Where can one go to vote for this feature?

                  I can't find the place on this website that allows people to vote on features. I even used your forum search to search for "SFT-2612" and I googled it, but no voting page was found.

                  Thanks again!

                  EquityTrader

                  Comment


                    #10
                    Hello EquityTrader,

                    They would be tracked through people requesting the feature through either this tread, another, or through email.

                    Please let us know if you need further assistance.
                    Alan P.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks, NinjaTrader_AlanP.

                      To all NinjaScript programmers who may ever want to create multi-instrument strategies:

                      Please vote for SFT-2612 by responding to this thread if you like using ExitLong(...) (and ExitShort(...), ExitLongLimit(...), etc.) method overloads without a quantity so that the NT8 execution engine knows to exit either your entire position, or your entire position that was entered with an entry order having a certain signal name, regardless of the number of entry orders and their signal names, and regardless of the number of exit orders already executed as part of your scaling out logic.

                      The problem for multi-instrument NinjaScript strategy programmers is that the only ExitLong(...) method overload that accepts a parameter for "barsInProgressIndex" also requires that "quantity" be provided as well.

                      The problem with being forced to provide a quantity is that you risk passing the wrong value. This is especially true if you scale in and out of positions.

                      By having quantity-less managed Exit(...) orders, you can rely on the NinjaTrader platform properly calculating the proper amount to exit, be it for a specific signal name or for the entire position.

                      Thank you for voting for SFT-2612,

                      EquityTrader

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Blairski, Yesterday, 09:19 AM
                      2 responses
                      9 views
                      0 likes
                      Last Post Blairski  
                      Started by tonynt, Today, 09:33 AM
                      1 response
                      6 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Started by minotti1, Today, 08:31 AM
                      1 response
                      13 views
                      0 likes
                      Last Post NinjaTrader_Jim  
                      Started by SmartArtsStudio, 05-15-2021, 10:46 AM
                      1 response
                      15 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by Airwave, Today, 06:02 AM
                      2 responses
                      23 views
                      0 likes
                      Last Post NinjaTrader_BrandonH  
                      Working...
                      X