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 NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        96 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        154 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        82 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        54 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        72 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X