Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Current Realized Profit in NInjaScript

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

    Current Realized Profit in NInjaScript

    Hello All-

    I want to add a condition for an exit that will include something along the lines of the Realized Profit on that specific trade.

    Background on my strategy:

    The strategy will buy X number of contracts and sell half if the price moves 16 ticks in my favor.
    Once it hits 16 ticks, the strategy sells half of the contracts and lets the others run.
    It trades on the 15, 30, and 60 timeframes.
    I have specific entries for each, "15Long" or "15Short", etc

    I originally had language based on Position Quantity but I ran into issues if I got a partial fill. I am thinking that something along the lines of

    if RealiedProfit of "15Long" > $0

    {

    Do Something

    }

    I just don't know what the code would be for the part with the red text above. And it would have to reset after the "15Long" trade closes so the next time "15Long" occurs, it doesn't register there being profit from the last trade.

    Could you help me out please?

    Thank you,

    Nick

    #2
    Hello njmeyer713,

    You can find a sample in the following link that shows how to work with realized profit. You need to reset it each day because the strategy has access to the historical realized pnl as well. If you wanted to limit the PnL to specific trades you would do the same general steps of storing the current PnL so you can reset the running PnL value by subtracting the stored pnl from the current PnL.

    https://ninjatrader.com/support/help...nce_statis.htm

    You can additionally find some information in the help guide here about getting the last trade information if you wanted to know an individual trades performance: https://ninjatrader.com/support/help...collection.htm

    Last edited by NinjaTrader_Jesse; 04-22-2022, 11:12 AM.

    Comment


      #3
      Thank you for the response.

      Another question,

      what does the 3s Buy Stp mean in the attached photo?

      Sometimes its a 2s or 4s as well.

      Thank you,

      Nick
      Attached Files

      Comment


        #4
        Hello njmeyer713,

        That would indicate the quantity or orders at that price.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        90 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        137 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
        120 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        71 views
        0 likes
        Last Post PaulMohn  
        Working...
        X