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 Mindset, 04-21-2026, 06:46 AM
            0 responses
            87 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            128 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            65 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            117 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            67 views
            0 likes
            Last Post PaulMohn  
            Working...
            X