Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Daily loss limit (account stop limit)

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

    Daily loss limit (account stop limit)

    Is it possible to set a daily loss limit for an account in Ninja? I'm thinking if in case a limit order gets filled accidentally, or something goes wrong, that Ninja can flatten an account or suggest doing so, perhaps sending an email, anything like this to protect account blowing up.

    No problem if not...

    #2
    Hello Crimsonite,

    Thank you for your post.

    Using the methods and properties Performance, Trade class and TradeCollection class you can create a filter to stop a strategy based on performance of the strategy.

    For a reference on stopping a strategy after consecutive losers please visit the following link: http://www.ninjatrader.com/support/f...ad.php?t=19289

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

    Comment


      #3
      I believe the following sample will be even more beneficial to the thread starter:

      Comment


        #4
        Hi Crimsonite, is about your observation Daily stops, or daily limit account loss, you found some information?

        Comment


          #5
          The strategy found by downloading the zip file(s) will handle not initiating new trades from best I can tell. But what if we are running several strategies simultaneously and want to monitor an overall, net, PnL for the account.

          Is it possible to utilize code within OnBarUpdate and/or OnMarketData for both a REALIZED and UNREALIZED PnL across all strategies...and if the net result is say, over $1000 net for the day; flatten everything?

          This of course would exit all positions and render all strategies disabled.

          Any ideas?

          Thanks.


          Brian

          Comment


            #6
            Hello brirob14,

            Thank you for your note.

            You could call NinjaTrader.Gui.SuperDom.SuperDom.FlattenEverythin g(); to flatten everything on the account.

            To pull the account values you would need to utilize the code below:
            Code:
            foreach (Account acct in Cbi.Globals.Accounts)
            {
            if (acct.Positions != null)
            {
            PositionCollection positions = acct.Positions;
            foreach (Position pos in positions)
            {
            Print(pos.Account.Name + " " + pos.Instrument + " " + pos.MarketPosition + " " + pos.Quantity + " " + pos.AvgPrice);
            }
            }
            Keep in mind these items are undocumented.

            Comment


              #7
              A little example of what I did for that situation:

              Code:
              if ( (Performance.RealtimeTrades.TradesPerformance.Currency.CumProfit> stopdailyamount && stopdaily==true) || (Performance.RealtimeTrades.TradesPerformance.Currency.CumProfit<-stopdailyamount && stopdaily==true))
              {
              	ExitLong();
              	ExitShort();
              	SendMail ("[email protected]", "[email protected]", "DAILY P/L LIMIT REACHED ", Position.MarketPosition.ToString() + " " + Position.Quantity.ToString() + "     PnL " + Performance.RealtimeTrades.TradesPerformance.Currency.CumProfit.ToString("0.00") );
              	return;
              }
              Where "stopdailyamount" is a variable to enter the daily limit amount
              Where "stopdaily" is a boolean variable that says whether that limit is active or not

              I hope this can help you
              Last edited by pstrusi; 09-24-2015, 02:35 PM.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by ETFVoyageur, Today, 04:00 PM
              1 response
              7 views
              0 likes
              Last Post ETFVoyageur  
              Started by AaronKTradingForum, Today, 03:44 PM
              1 response
              8 views
              0 likes
              Last Post AaronKTradingForum  
              Started by Felix Reichert, 04-26-2024, 02:12 PM
              11 responses
              77 views
              0 likes
              Last Post Felix Reichert  
              Started by junkone, 04-28-2024, 02:19 PM
              7 responses
              83 views
              1 like
              Last Post junkone
              by junkone
               
              Started by pechtri, 06-22-2023, 02:31 AM
              11 responses
              139 views
              0 likes
              Last Post Nyman
              by Nyman
               
              Working...
              X