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

Lock in Realized profit from unrealized profit at a certain number

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

    Lock in Realized profit from unrealized profit at a certain number

    Hi team!

    I already have a bool set up for shutting the system off when it reaches a certain amount up or down. However that is only when the position closes.

    Is there a way through the strategy builder that I can shut it off at a total market position profit target?

    For example: Realized gains = $500. Currently in a move for unrealized gains $1234. I want to shut the move off when realized gains would equal $1,000 for the day not the singular trade.

    Is this possible?

    #2
    Hello litamm89,

    Thanks for your post.

    If I understand correctly you want to add your realizedPNL to the unrealizedPNL and close the open trade when you are >= $1000.

    You can access both realized and unrealized PNL in the conditions builder under the Strategy Folder.

    To add them together though you would need to create a custom double series that would allow you to do the "Offset" of adding them together.

    Below is a screenshot of adding them together into the custom series. You would do just as this set shows with no conditions so that the custom series "TotalPNL" will always reflect the realized plus the unrealized.

    In another set, you would use TotalPNL[0] as the trigger to close the trade and stop trading.


    Click image for larger version

Name:	SBtotalPNL.PNG
Views:	663
Size:	26.9 KB
ID:	1159739
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      NinjaTrader_PaulH

      Thanks for your response.

      You are correct in your understanding that is exactly what I am trying to do.

      I apologize I am not as advanced as I was hoping I was.

      Could you break this down a little further as in to what inputs I do and where?

      In the additional Data. I found the custom series and created a double series. Could you show me what the inputs would look like?

      Comment


        #4
        Hello litamm89,

        Thanks for your reply.

        It is tricky to set this up so I thought a short video would be helpful:



        Paul H.NinjaTrader Customer Service

        Comment


          #5
          NinjaTrader_PaulH

          Update:

          I have created the TotalPNL under Additional Data, Custom Series, Double.

          My screen now looks like yours except I couldnt figure out in the second Action how you added the TotalPNL.

          Mine reads: TotalPNL[0]=Position.GetUnrealizedProfitLoss(PerformanceUnit. Currency,Close[0]);

          This is just the set that adds the "offset" together correct?

          I believe I will also need help with the closing set as you have stated as well.

          Thank you again for all your help. I really appreciate it.

          Comment


            #6
            I didnt see your response. You are very efficient haha let me check the video.

            Thank you for your patience

            Comment


              #7
              NinjaTrader_PaulH

              That video was immensely helpful and so much easier to follow!

              Would it be possible to do another video for the other set?

              I am trying to create it in actions and conditions but cant find the user variable as an option.

              Also in addition to having the trade exit is there another alternative to set the $1,000 at a breakeven point and reset a trailing stop loss?

              So basically set a stop loss at $1,000 but allow the trade to continue?

              Comment


                #8
                Hello litamm89,

                Thanks for your reply.

                As I mentioned in the video and in post#2, you would need to use TotalPNL[0] which can be found MIsc>Custom series in the conditions builder. The condition then would be on the left Misc>Custom series>TotralPNL, center would be greater, on the right would be Misc>Numeric Value> and enter the value you want to exit the trade at. In the action section, you would use the exit order needed, exitlong or exitshort.

                "Also in addition to having the trade exit is there another alternative to set the $1,000 at a breakeven point and reset a trailing stop loss?

                So basically set a stop loss at $1,000 but allow the trade to continue?"


                That may be possible but you likely would need to unlock the strategy and work in Ninjascript.

                If you would like something created for you, we can provide a link to 3rd party programmers in the NinjaTrader Ecosystem that would be able to meet your programming needs.
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  NinjaTrader_PaulH

                  I swear I looked there and it wasnt there.....but now that you said it it magically appeared like when you try to find something and you cant and then your wife finds it in a second and just looks at you......

                  Paul you are truly amazing at your job and I am so grateful for you.

                  Thank you for being so patient with me and answering everything so efficiently and on point.

                  I hope you have a great day!

                  Comment


                    #10
                    NinjaTrader_PaulH

                    Quick question about this TotalPNL is this calculated on the TotalPNL of the strategy I set or the total account?

                    For example if I want the strategy to cut off when it reaches $500 but I have done some manual trading outside of the strategy using my real account totaling more than the $500. Lets say $825, will the strategy not execute any trades because the account is already at the profit limit set for the strategy?

                    Comment


                      #11
                      Hello litamm89,

                      Thanks for your reply.

                      It would be of the strategy PNL only, it does not know of your account PNL or other trades or other strategies PNL.

                      Paul H.NinjaTrader Customer Service

                      Comment


                        #12
                        NinjaTrader_PaulH

                        Beautiful thats the exact answer I wanted.

                        Have a great weekend

                        Comment


                          #13
                          Will this work also for the Strategy to stop working overall instead of just exiting current trades???

                          Comment


                            #14
                            Hello rafael_delima86,

                            Thanks for your post.

                            You can create a bool variable that is set true by default and when the strategy PNL exceeds a value you set it false. The bool could be used as an entry condition so when the PNL has exceeded your limit the bool could be set to false and no more trade entries would occur until the bool was reset, for example at the first bar of a new session.



                            Paul H.NinjaTrader Customer Service

                            Comment


                              #15
                              Hello Paul, thanks for your quick reply…
                              Is this right? “LIMITPnL” is an Input that I added to set whenever I enable the strategy. Should I add another set with the bool = true with Total PnL >=LIMITPnL on CONDITION and then set the action to BOOL=False?

                              I’m having a really hard time knowing which place I should add the bool = true and false

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by JoMoon2024, Today, 06:56 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post JoMoon2024  
                              Started by Haiasi, 04-25-2024, 06:53 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post Massinisa  
                              Started by Creamers, Today, 05:32 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post Creamers  
                              Started by Segwin, 05-07-2018, 02:15 PM
                              12 responses
                              1,786 views
                              0 likes
                              Last Post Leafcutter  
                              Started by poplagelu, Today, 05:00 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post poplagelu  
                              Working...
                              X