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

Max daily loss limit

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

    Max daily loss limit

    Good morning,

    New here, hopefully this is in the right spot, I am looking for a way to set up a maximum dollar daily loss in ninja trader 7 for $1000. Do you guys know of a way to do this? Looking for ninja trader to not allow new trades to be executed if the daily P/N reaches ($1000). Just like a prop account would have.

    I found a couple threads were people were talking about it but nothing solid. I am not good at righting code with ninja trader, I am a day trader and I just use them for there "on the chart trading" so I figured I would come ask the experts.

    Any help would be greatly appreciated.

    Thanks,

    Alyssa

    #2
    Hello Alyssa,

    Thanks for writing in, and welcome!

    There is not a supported way to prevent manual order submissions through NinjaScript, but you can add logic to a NinjaScript strategy so that strategy will cease firing orders after the Account's realized PnL reaches a certain point.

    This can be done by checking the PnL with one of the methods below, and then setting a bool that controls your trading logic so the trades no longer fire.

    Account realized PnL can be retrieved with GetAccountValue() - https://ninjatrader.com/support/help...countvalue.htm

    Account Unrealized PnL would not be attainable through NinjaScript in NinjaTrader 7, but you could get the strategy's Unrealized PnL with Position.GetProfitLoss() - https://ninjatrader.com/support/help...profitloss.htm

    NinjaTrader 8 can see the Unrealized PnL on the account with https://ninjatrader.com/support/help...itemupdate.htm

    If you would like to get connected with a NinjaScript consultant that would be eager to make these changes for you, please let me know and I'll have a member of our business development team reach out with more information on NinjaScript Consultants.
    Last edited by NinjaTrader_Jim; 03-02-2018, 08:09 AM.
    JimNinjaTrader Customer Service

    Comment


      #3
      Good morning,

      Thanks Jim.

      Yes if I could talk to someone about this that would be great.

      Thanks

      Comment


        #4
        Hello Alyssa,

        You can search our extensive library of vendors who provide programming services through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more!





        You can locate the contact information for the consultants on their direct websites for any additional questions you may have. Since these consultants are third party services for NinjaTrader all pricing and support information will need to be obtained through the consultant.


        This NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.


        Please let me know if you have any questions, concerns or if I can provide any further assistance by responding to this thread at your convenience.
        Ryan L.NinjaTrader Customer Service

        Comment


          #5
          daily profit loss limit

          I know you said NT7, but if you've upgraded, here's some NT8 code that does this. Link

          Comment


            #6
            Hello,

            I just noticed an undocumented property DailyLossLimit on the Account object and it appears to work as expected.

            Create a new AddOn and:

            protected override void OnStateChange()
            {
            if (State == State.SetDefaults)
            {
            Account myAccount = Account.All.FirstOrDefault(a => a.Name.Contains("Playback"));
            myAccount.DailyLossLimit = 100;
            }
            }


            As soon as this is compiled you can trade manually and once the loss limit is exceeded, NT8 will not allow order submission and will display attached error.


            Hopefully someone from NT can comment on this property and its correct usage.

            Comment


              #7
              Hello mindozas,

              Unfortunately, this is not a documented NT8 property so I really couldn't advise using this in your custom code. It appears by the error in the image that this use case did work, the error produced seems like a standard NinjaTrader error message that may come from using this. Unfortunately, we dont have any information on this property for me to provide an expectation or help here.

              If you are trying to control your losses from an addon, I would suggest that you create a new thread in the NT8 Addon development forums for further assistance or ideas. There is not really anything I could suggest that you could use for this purpose as there is no documented/supported way to block manually placed trades while using NinjaScript. You would just need to stop trading once you reach your personal goal limits.

              Please let me know if I may be of further assistance.
              JesseNinjaTrader Customer Service

              Comment


                #8
                Is it possible to accomplish Daily PnL Limits for example with the Strategy Builder? I read in another thread that you were supposed te create a new Variable (bool) "OkToTrade" and set it to True, then in the conditiones group you Choose If ANY -- Pnl>400 and PnL<-200 then bool variable OkToTrade would set to flase. Anyway it didn´t work for me. Can anybody explain to me how can disable the strategy or cancel Order as soon as the Realized or Unrealized PNL is outside -200>-PnL>400 this interval???

                Comment


                  #9
                  Hello alvaroramiro,

                  Thank you for the post.

                  When you say it did not work, how so? Were you still seeing trades or were no trades being placed?

                  Were you using the Realized profit in your condition?

                  Had you additionally added conditions to your other sets to check if OkToTrade is true? Each set would need that added so that when OkToTrade is false the trade conditions no longer work.


                  I look forward to being of further assistance.
                  JesseNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by CortexZenUSA, Today, 12:53 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post CortexZenUSA  
                  Started by CortexZenUSA, Today, 12:46 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post CortexZenUSA  
                  Started by usazencortex, Today, 12:43 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post usazencortex  
                  Started by sidlercom80, 10-28-2023, 08:49 AM
                  168 responses
                  2,266 views
                  0 likes
                  Last Post sidlercom80  
                  Started by Barry Milan, Yesterday, 10:35 PM
                  3 responses
                  13 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Working...
                  X