Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

set commission in code behind

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

    set commission in code behind

    Hi,

    I’d like to ask if there is some possibility to reach in code behind, that in a given strategy and backtest, the amount of commission could be set by me manually in each and every order. If so, could You please let me know, how?

    I need it, because I’d like to see these ones in the end result of a backtest, in order to see the results on a chart accordingly, etc…

    I looked for it, but couldn’t find it possible or did I miss something?

    #2
    Hi tamas, here is an overview what you can set in the strategy Initialize() directly - http://www.ninjatrader-support2.com/...06&postcount=5

    Proper commissions need to be entered first in the Instrument Manager, here's how - http://www.ninjatrader-support.com/H...issionTab.html

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Hi tamas, here is an overview what you can set in the strategy Initialize() directly - http://www.ninjatrader-support2.com/...06&postcount=5

      Proper commissions need to be entered first in the Instrument Manager, here's how - http://www.ninjatrader-support.com/H...issionTab.html
      Hi Bertrand,

      thanks, but my question: "the amount of commission could be set by me manually in each and every order. " in code behind. (not in commission tab).

      Possible set in C# code? (Property, method, etc?)

      Waiting for your reply,

      Comment


        #4
        Hi tamas, unfortunately this is not supported.

        Comment


          #5
          tamas,

          You could run your own variable to track the commissions you want. Then just subtract it from your total net profit at the end.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Josh View Post
            You could run your own variable to track the commissions you want. Then just subtract it from your total net profit at the end.
            Good idea, thanks

            Originally posted by NinjaTrader_Bertrand View Post
            Hi tamas, unfortunately this is not supported.
            Will nt7 support it? If no, could it be possible to forward this suggestion to development for future consideration?

            Comment


              #7
              NinjaTrader 7 features will be announced when available - Thank you for the suggestion, we appreciate it.

              Comment


                #8
                I have the same question for NT7 (this thread was a question about NT6.5):

                With NT7, can you define the commission value using code either in Initialize() or elsewhere within the strategy code?

                Thanks,

                Aventeren

                Comment


                  #9
                  There's no change in this area Aventeren (thought for sure continued to be tracked), it would not be a property you could set dynamically via NinjaScript code. What would be available in contrast is one for slippage in ticks per execution.

                  Comment


                    #10
                    Originally posted by NinjaTrader_Bertrand View Post
                    There's no change in this area Aventeren (thought for sure continued to be tracked), it would not be a property you could set dynamically via NinjaScript code. What would be available in contrast is one for slippage in ticks per execution.
                    Thanks, Bertrand; that's what I suspected.

                    The challenge with backtesting a strategy that assumes market orders on both sides, is that you cannot test an odd number of roundtrip slippage (i.e., 3 ticks roundtrip slippage) due to the fact that the NT7 backtest engine applies slippage to first the entry and then the exit--but the result would either not be rounded to tick size (which would yield an incorrect backtest) or the engine would try and round the result (which would either round to 1 or 2 ticks per side, which would therefore yield an incorrect backtest).

                    Therefore, I was thinking about just bagging the slippage variable entirely, and just plugging the commission + slippage into the Tools > Options > Commissions > Futures - Simulator > Commission value (i.e., $2.50 + (3 ticks * $12.50/tick)/2 = $21.25. Then I could be assured of an accurate net backtest with commission and 3 ticks roundtrip slippage. But to do this requires changing the Commission value for each instrument before the backtest run, as tick sizes change by instrument. Therefore, I was hoping to just be able to change the Commission value within the code.

                    The other workaround to get to 3 ticks roundtrip slippage would be to assume a limit order entry (because no slippage would be applied) and then use 3 ticks slippage in the Strategy Analyzer with a market order for the backtested exit. But again, this is a pain in the ass, too.

                    Therefore, I was hoping to just be able to change the Commission value in code.

                    Given that NT7 cannot set Commission value within the code, can you please see that this request is made for NT8? For instance, it would be cool if we could access the Tools > Options > Commissions > Futures - Simulator > Commission value by typing something like this (it won't be this, but you get my point):

                    Code:
                    protected override void Initialize()
                            {
                                            Tools.Options.Commissions.FuturesSimulator.CommissionValue = 21.25;
                            }
                    Again, I get that the path would not be what I've typed in above, but basically you would allow us to access the Commission value parameter via code so that we could then code in a conditional if or switch statement within Initialize() to automatically set the instrument specific Commission value.

                    Let me know what you think--and what you believe the relative odds to gaining access to the Commission value variables within NT8.

                    Thanks,

                    Aventeren

                    Comment


                      #11
                      Aventeren, thanks for the detailed reply and including your scenario, I can very well understand.

                      I could not give you an ETA or commitment or any odds, however I have made sure your thoughts are noted in product enhancement tracking list that product management works very actively with in the evolution of our platform.

                      Perhaps a thought - if you were submitting marketable limit orders you could potentially control the slippage, too via the limit price you submit at (as with the fill type per default you would get a fill at your price spec'ed and never better). However the limit would be here the bar's range.

                      Comment


                        #12
                        Originally posted by NinjaTrader_Bertrand View Post
                        Aventeren, thanks for the detailed reply and including your scenario, I can very well understand.

                        I could not give you an ETA or commitment or any odds, however I have made sure your thoughts are noted in product enhancement tracking list that product management works very actively with in the evolution of our platform.

                        Perhaps a thought - if you were submitting marketable limit orders you could potentially control the slippage, too via the limit price you submit at (as with the fill type per default you would get a fill at your price spec'ed and never better). However the limit would be here the bar's range.
                        Not a bad idea, but I think for the mean time I'll just stick with my belt and suspenders approach, which will be to modify the Futures - Simulator > Commission value specific to each instrument before each back test--that way I can be certain that my desired commission and slippage will be included as I'd like.

                        Perhaps the "Commission value" will be code accessible in NT8--however we can only wait and see.

                        Thanks,

                        Aventeren

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        606 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        353 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        105 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        560 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        561 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X