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