Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

max/min profit open position

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

    max/min profit open position

    Hi,
    What code in the library do i need to get the max and min profit values (mfe and mae in dollars) of an open position as of the close of the last bar?
    thanks,
    David

    #2
    Hi David, thanks for posting. A running MAE and MFE value for an open position will need to be calculated manually from within your script, there is no function that will return it built into the NinjaScript library. In OnBarUpdate, if in a position, check the value of Position.GetUnrealizedPnL() and save this value to a class-level variable.

    Comment


      #3
      can we access the values for a closed position? Print MFe, MaE?

      Comment


        #4
        Hi David, you can get this value through the Trade object. In a strategy, we can access the AllTrades array through SystemPerformance, which is a collection of all the trades made by the strategy, each entry in this list is a Trade object, which has various properties, including MAE and MFE:


        Comment


          #5
          awsome, thx

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          43 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          21 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          30 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          50 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          40 views
          0 likes
          Last Post CarlTrading  
          Working...
          X