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 NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          64 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          139 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          75 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          45 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          50 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X