Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to calculate lots considering commission and fee

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

    How to calculate lots considering commission and fee

    Hello, NT traders and supports.
    ​I am fascinated by NinjaTrader, but I am still a beginner and there is so much I don't know.
    If anyone knows how to calculate lots considering commission and fee, please tell me.
    Don't blame me for asking something basic, but please enlighten me.
    Thanks again for advice.

    #2
    Hello truepenny,

    Thank you for your post.

    To clarify, you want to calculate quantity based on commissions and fees?

    You would need to come up with your custom logic for calculating the quantity based on commissions and fees.

    You can access commissions info through the TradePerformance collection.



    Or for a specific trade's commissions, you can obtain the commissions through the Trade object.



    Fees vary by broker and there is no way to access custom fee info through NinjaScript. You'll need to calculate the fees manually.

    Please let us know if you have any further questions.

    Comment


      #3
      Hello, Gaby. I express my sincere respect for your warm assistance.
      I have some questions.
      -How do I calculate the quantity once I get the commission?
      -How do I calculate fees manually?

      In short, I want to open the following market positions when I press the button:

      SL : input SL/PIPS distance used
      Target : Uses RR to set it
      Lots :
      - Uses Risk in%
      - Must be an even number, NEVER odd number. Because with SLF buJon, we will close Half.
      Example with futures : if Lot calcula@on gives 3.56 lots, you will use 2 because we can not
      have 3/2 with half buJon.
      so : 4.2 will give 4
      7.9 will give 6
      2.1 will give 2
      1.9 or lower will give 0 (no order with a message box : Reduce SL)

      But I dont know about calculating them so my code is not work well.

      Can you lead me about that?​


      Your wealth of knowledge and experience makes me immersed in the world of ninjatrader. Thanks.

      Comment


        #4
        Hello truepenny,

        As mentioned, you will need to come up with your own custom logic for calculating this based on commissions and fees. Unfortunately, in the support department at NinjaTrader it is against our policy to create logic for our clients.

        By calculating fees manually I meant you will need to get the information about what fees you are charged per trade from your broker and include these in your custom calculation. Unfortunately I am unaware of any way to programmatically access information about what fees are charged to your account via NinjaScript.

        Please let us know if you have any further questions.

        Comment


          #5
          Hi, Gaby and marcus. thanks for your replies.

          Comment


            #6
            Below calculates PositionSize and is self explanatory.
            It does NOT include commissions

            rawQ =(DollarsAtRisk/(((shortStopPrice - shortTradePrice)/TickSize)* Instrument.MasterInstrument.PointValue*TickSize))) ;
            ​double setmaxmin = Math.Min(rawQ,maxContracts);// set a max no of contracts
            setmaxmin = Math.Max(1,setmaxmin);// set minimum to 1 contract
            myQ = Convert.ToInt32(setmaxmin);​

            ps you can use round functions, etc and commission templates to make it better but this is the raw function.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            44 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            126 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            65 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            42 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X