Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problems with order quantity

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

    Problems with order quantity

    I have a few questions about quantity with regards to EnterLong() and EnterShort()

    How does default quantity work?

    If you are in a short position, and you enter a long position does it exit the short position?

    Is there code for finding the cash value of the current position?

    Are there any general tips for determining order quantity?

    #2
    Is there a reason that my current quantity method works with back-testing, but returns errors with simulated trading?

    Comment


      #3
      Hello,
      Default Quantity will set it so that all Enter and Exit orders use the same default quantity. This is set either in the Order from the Strategies parameter menu or can be set in Initialize(). Please see the following link on Default Quantity. http://ninjatrader.com/support/helpG...ult%2Bquantity

      If you are using Default Quantity and EnterLong() and then EnterShort this would not leave you in a flat position. EnterLong() would bring you into a long position and then when EnterShort() would then reverse the position, first bringing it to a flat position and then leaving you in a Short position equal to your Default Quantity.

      You can find Profit and Loss of the current position using a Strategy by calling Position.GetProfitLoss(). Please see the following link on Position.GetProfitLoss(),http://ninjatrader.com/support/helpG...profitloss.htm

      You can get your Positions Quantity by calling Position.Quantity. Please see the following link on Position.Quantity, http://ninjatrader.com/support/helpG...7/quantity.htm
      If you are looking for recommendations on determining what your trading quantity should be we would not be able to provide this information as this would be trading advice.

      Can you elaborate on what quantity method you are using and what errors you are receiving?
      Cody B.NinjaTrader Customer Service

      Comment


        #4
        Thanks for the quick reply.

        DefaultQuantity = (int)(GetAccountValue(AccountItem.CashValue) +
        (Position.Quantity * Close[0]));
        This would set trade amount to the account size, right? If this was combined with CalculateOnBarClose = true then DefaultQuantity would be updated ever bar. I know this seems obvious, but I'm just making sure.


        On a side note, I can't find the code for the commission rate for the current instrument. Could you please tell me what it is?

        Comment


          #5
          The above code to change default quantity makes the program unusable by the optimizer. Is there a way around that?

          Comment


            #6
            Disregard the previous posts, fixed the problem. May I still have the commission codes, please? Thanks!

            Comment


              #7
              Hello,
              There is not a supported way to get the commissions values set from the instrument manager. You can get the Commission as part of the TradePerformance, this will be the performance of the strategies run. Please see the following link on TradePerformance.Commission. http://ninjatrader.com/support/helpG...commission.htm

              Through unsupported code users have been able to get the commissions from the instrument manager. Please see the following post on this. http://ninjatrader.com/support/forum...ad.php?t=39019
              If we can be of any other assistance please let us know.
              Cody B.NinjaTrader Customer Service

              Comment


                #8
                I continue to get error messages with regards to trying to trade too much. What is the best way to find the max quantity that I can trade?

                Comment


                  #9
                  Hello CriticalMind,

                  Your broker will have this information for your you. If you are trading in Sim101 and getting such a message please detail the message in your response.

                  Comment


                    #10
                    Thanks for the advice.

                    I am still getting errors that I'm ordering too much. My code goes as follows:

                    int quantityToTrade = (int)(GetAccountValue(AccountItem.CashValue)/Close[0]);
                    EnterLong(quantityToTrade);

                    Why would this give a value greater than the size of the account?

                    Comment


                      #11
                      Hello,
                      From the code I do not see the code taking in account for the commissions. The commissions would need to be added in as you would need to cover this for your entry trades.
                      Cody B.NinjaTrader Customer Service

                      Comment


                        #12
                        Great! Sounds like a solid answer to what's going on. I've been scratching my head on this for a bit too long LOL.
                        So it should be
                        (Cash Amount of Account - Commisison) / current price

                        What is the best code to find the commission? I suppose I could hard code it, but that seems a bit inelegant.

                        Comment


                          #13
                          Hello,
                          There is not a supported way to get the commission set. The supported method would be to hard code in the commissions.
                          Through unsupported code users have been able to get the commissions from the instrument manager. Please see the following post on this.

                          If we can be of any other assistance please let us know.
                          Cody B.NinjaTrader Customer Service

                          Comment


                            #14
                            Alright, hard code it is.
                            So I am using Ninjatrader Brokerage with a Ninjatrader Lease. That means .73 per contract, right? So that means .73 per quantity to trade?

                            So max trade quantity is
                            Cash / (current price + .73)

                            Is that right? I feel really dumb asking such basic questions, but I'm getting a bit frustrated. Thanks.

                            Comment


                              #15
                              Hello,
                              As I am not a broker I would not be able to confirm what your commissions are. Please send a note to brokeragesupport[AT]ninjatrader[DOT]com to verify your commissions.

                              Your logic is correct. You would use Account Cash Value / (current price + commission)
                              Cody B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Kaledus, Today, 01:29 PM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by frankthearm, Yesterday, 09:08 AM
                              13 responses
                              45 views
                              0 likes
                              Last Post frankthearm  
                              Started by PaulMohn, Today, 12:36 PM
                              2 responses
                              16 views
                              0 likes
                              Last Post PaulMohn  
                              Started by Conceptzx, 10-11-2022, 06:38 AM
                              2 responses
                              55 views
                              0 likes
                              Last Post PhillT
                              by PhillT
                               
                              Started by yertle, Yesterday, 08:38 AM
                              8 responses
                              37 views
                              0 likes
                              Last Post ryjoga
                              by ryjoga
                               
                              Working...
                              X