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 arvidvanstaey, Today, 02:19 PM
              3 responses
              9 views
              0 likes
              Last Post NinjaTrader_Zachary  
              Started by jordanq2, Today, 03:10 PM
              2 responses
              8 views
              0 likes
              Last Post jordanq2  
              Started by traderqz, Today, 12:06 AM
              10 responses
              18 views
              0 likes
              Last Post traderqz  
              Started by algospoke, 04-17-2024, 06:40 PM
              5 responses
              47 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by mmckinnm, Today, 01:34 PM
              3 responses
              7 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X