Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Commission value?

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

    Commission value?

    It appears that:
    Code:
    LastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1];
    
    Commission = LastTrade.Commission;
    ​
    When a partial order is filled, it will report the commission of the last trade of the partial fill. So if the order is for 20 contracts (MES, comission is $24.40) and 19 are partially filled, then the last trade is 1 contract (MES comission is $1.22) then the above code will return a comission of $1.22.

    What I would like to get instead is the comission of the entire order of 20 contracts.

    Currently I'm using this code:
    Code:
    protected override void OnPositionUpdate(Position position, double averagePrice, int quantity, MarketPosition marketPosition)
    
    {
    
    if (Position.MarketPosition == MarketPosition.Flat && SystemPerformance.AllTrades.Count > 0)
    
    {
    
    if (Position.MarketPosition == MarketPosition.Flat && SystemPerformance.AllTrades.Count > 0)
    
    {
    
    if (Position.Instrument.FullName == Instrument.FullName)
    
    {
    
    string OrderAction = "";
    
    string OrderType = "";
    
    double EntryPrice = 0;
    
    double ExitPrice = 0;
    
    double GrossProfit = 0;
    
    double NetProfit = 0;
    
    double Commission = 0;
    
    double Fees = 0;
    
    Trade LastTrade;
    
    
    
    // Get commission for the order/position
    
    LastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1];
    
    Commission = LastTrade.Commission;
    ​

    #2
    Hello Skechers,

    Thank you for your post.

    When an order is partially filled, it is a separate Trade in the TradeCollection. You are getting the commission of the last trade of the partial fill because you are only working with LastTrade.Commission. If you want all commissions for the separate partial fills added together, you may need to modify your code to evaluate multiple trade objects and not just the last trade. You may verify what values and quantities you are working with by adding prints, such as printing the count to get the number of trades in the collection (SystemPerformance.AllTrades.Count) as well as printing a trade ToString(), like LastTrade.ToString(). For more details on Trade objects, TradeCollection, and SystemPerformance.AllTrades, please see the links below:Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      How do I access the comission value for 1 contract?

      Thanks!

      Comment


        #4
        Hello Skechers,

        Thank you for your reply.

        Getting a commission value from an instrument is not currently supported. I can add your vote to feature request SFT-1645. If this feature is included in a future release, it will be listed in the release notes:


        That said, there is some code that is not documented in the help guide that you could try as mentioned here:


        Please let us know if we may be of further assistance.
        Emily C.NinjaTrader Customer Service

        Comment


          #5
          Many Thanks Emily!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Haiasi, 04-25-2024, 06:53 PM
          2 responses
          17 views
          0 likes
          Last Post Massinisa  
          Started by Creamers, Today, 05:32 AM
          0 responses
          5 views
          0 likes
          Last Post Creamers  
          Started by Segwin, 05-07-2018, 02:15 PM
          12 responses
          1,786 views
          0 likes
          Last Post Leafcutter  
          Started by poplagelu, Today, 05:00 AM
          0 responses
          3 views
          0 likes
          Last Post poplagelu  
          Started by fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,408 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Working...
          X