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

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.
    Chris L.NinjaTrader Customer Service

    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:


        Chris L.NinjaTrader Customer Service

        Comment


          #5
          awsome, thx

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          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,407 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by Shai Samuel, 07-02-2022, 02:46 PM
          4 responses
          98 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by DJ888, Yesterday, 10:57 PM
          0 responses
          8 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          160 views
          0 likes
          Last Post loganjarosz123  
          Working...
          X