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

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.
    JesseNinjaTrader Customer Service

    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.

        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by fleconkey, Today, 06:40 AM
        0 responses
        0 views
        0 likes
        Last Post fleconkey  
        Started by manueldecastro, Yesterday, 10:26 AM
        6 responses
        26 views
        0 likes
        Last Post manueldecastro  
        Started by cmtjoancolmenero, 04-29-2024, 03:40 PM
        24 responses
        75 views
        0 likes
        Last Post cmtjoancolmenero  
        Started by businessman1929, 04-29-2024, 01:28 PM
        3 responses
        32 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by mintos, 04-02-2024, 08:22 PM
        3 responses
        27 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X