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

Daily loss limit examples

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

    Daily loss limit examples

    Hello,

    I've updated the DailyLossLimit and DailyLosLimitMultiTrade examples that were posted on the forum for NinjaTrader 7 for NinjaTrader 8.

    These are often requested and I felt they are good examples to have for NT8.

    DailyLossLimitExample_NT7 - http://ninjatrader.com/support/forum...241#post451241

    DailyLossLimitMultiTradeExample_NT7 - http://ninjatrader.com/support/forum...367#post475367

    Update Sep 4th, 2018:
    - I realized the print in OnPositionUpdate should print when currentPnL is equal to less than the LossLimit, not just less than it.

    Update July 13th, 2020:
    - Added DailyLossLimitBuilderExample_NT8; NinjaTrader_PaulH was clever enough to realize the Strategy Builder custom series can be used with offsets to do math and subtract the total pnl from yesterdays pnl to get the current pnl and provided an example.

    DailyLossLimitMultiTradeExample_NT8.zip
    DailyLossLimitExample_NT8.zip
    DailyLossLimitBuilderExample_NT8.zip
    Attached Files
    Last edited by NinjaTrader_ChelseaB; 07-13-2020, 09:39 AM.
    Chelsea B.NinjaTrader Customer Service

    #2
    excellent...thank you

    Comment


      #3
      Here's some more NT8 code that does this.

      (link removed - no longer valid)
      Last edited by NinjaTrader_Manfred; 12-28-2022, 08:48 PM. Reason: link removed - no longer valid

      Comment


        #4
        Hello Chelsea,
        Could you please help me. I would like to have an add-on that will stop all my positions if I reach 300$ loss?
        How do I need to adjust this strategy so NT8 stops me out if I reach 300$ daily loss?
        Let's say, I trade in the morning and at some point I reach 300$, so NT 8 will exit automatically from all my positions...
        Thank you!

        Comment


          #5
          Hello peter_brv,

          To confirm you are making an Addon and not a NinjaScript Strategy, is this correct? All links below are publicly available.

          You are wanting to loop through all positions on all accounts?

          You would need to loop through the Account.All and for each account loop through the orders and custom calculate the PnL.



          You might be able to make a custom TradeCollection and fill it with orders, but this would be outside of what is supported by NinjaTrader Support.


          Then after collecting the PnL, you would need custom logic to loop through all positions and close the positions or call Flatten() on the account.

          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Thank you. Bad thing - I am not a programmer, so it'll be a challenge. I guess I 'll have to search for an engineer for this.
            The reason I wanted that add-on is to "discipline myself" and cancel trading for a day of 200$ loss....

            Comment


              #7
              Rookie question here. How do I view the DailyLossLimitExample_NT8.zip (1.6 KB, 1 view) once I import it?

              Comment


                #8
                For some reason, I had to import the script 3 or 4 times before it was visible in the NinjaScript Editor.

                Now the question is how do I use this in conjunction with the SampleMACrossOver strategy?

                Comment


                  #9
                  Hello JonTansey ,

                  Once the script is imported and a 'Ninajscript imported successfully' message appears, the script can be opened in the New > NInjaScript Editor > explorer pane on the right > Strategies section.

                  You would learn from what the script is doing, see how to collect performance and use this to exit trades and / or prevent new trades, and model the logic in your script similarly. This involves creating variables and using those in the conditions that place orders.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks Chelsea. Wish Ninja Trader would code this as an Indicator too that can be used in a Strategy. And also have another Indicator that would limit the number of total trades in a day too.
                    Thanks.

                    Comment


                      #11
                      Hello Trader17,

                      I have submitted your request for the NinjaTrader Development to consider creating a loss limit tool for NinjaScript Strategies.

                      Once I have a tracking ID for this request I will post in this thread for future reference.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Hello Trader17,

                        I have received tracking ID# SFT-2936 for this request for a daily loss limit built into NinjaScript Strategies.

                        Please note it is up to the NinjaTrader Development to decide if or when any request will be implemented.

                        We appreciate your feedback on this.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Thank you Chelsea. Does the example provided work intra bar also or just on a bar close?
                          Thank you.

                          Comment


                            #14
                            Trader17,

                            Chelseas sample is set up to calculate on bar close but could be modified to work intrabar as well
                            Josh G.NinjaTrader Customer Service

                            Comment


                              #15
                              Thank you. Could you ask Chelsea to try to make a similar example please which works intra bar also?
                              Thank you.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Barry Milan, Today, 10:35 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by WeyldFalcon, 12-10-2020, 06:48 PM
                              14 responses
                              1,428 views
                              0 likes
                              Last Post Handclap0241  
                              Started by DJ888, Yesterday, 06:09 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              40 views
                              0 likes
                              Last Post jeronymite  
                              Started by bill2023, Today, 08:51 AM
                              2 responses
                              16 views
                              0 likes
                              Last Post bill2023  
                              Working...
                              X