Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Maximum Daily Loss

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

    Maximum Daily Loss

    I know there's a similar thread where it was said that there was no way for NT to do this automatically. So, I've tried to achieve this through scripting but it doesn't seem to work. Any thoughts?

    protected override void OnBarUpdate()
    {

    if (Bars.FirstBarOfSession)
    {
    disable = 0;
    dayscapital = initialcapital + Performance.AllTrades.TradesPerformance.Currency.C umProfit;
    }

    if (initialcapital + Performance.AllTrades.TradesPerformance.Currency.C umProfit > daycapital * 0.97
    && disable == 0)
    {
    <<<continuetrading>>>
    }
    else
    {
    disable = 1;
    }

    What I'd expect is that as long as the daily loss is less than 3%, the script should <<<continuetrading>>>. But it doesn't seem to work. I have a stop loss of 1% on all trades so the max daily drawdown should be 4%. However, I have some with 6+%.

    I tried to troubleshoot this by adding a
    Print (dayscapital);
    on the last line of the first if clause, after the dayscapital has been calculated for the day.

    However, checking the output window, the dayscapital is never printed as 10000, which it should be at least once, on the first day before any trades have been completed (since initialcapital = 10000). Also, for some reason, other Print() commands on the first day have been outputted before the Print (dayscapital) even though they come later on in the script.

    Any help would be much appreciated. Thanks!

    -------
    EDIT:

    I tried this in another script where and it does seem to work. Could this by any chance be due to a problem this has with SetTrailStop?
    Last edited by wuileng; 08-30-2009, 11:24 AM.

    #2
    Hi wuileng, have you seen the sample titled Halting a Strategy Once User Defined Conditions Are Met?
    AustinNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Austin View Post
      Hi wuileng, have you seen the sample titled Halting a Strategy Once User Defined Conditions Are Met?

      Austin,

      Does the check against the maximum drawdown below consider both OPEN and CLOSED values?

      if (Performance.AllTrades.TradesPerformance.Currency. CumProfit > 1000
      || Performance.AllTrades.TradesPerformance.Currency.C umProfit < -400)

      I'd like to have a check that stops my strategy once my drawdown hits a certain amount. I want my drawdown calculated based off of open positions as well.

      thanks-

      Comment


        #4
        jonmoron, this would only include closed trades. You could work with the closed trades performance along with GetProfitLoss() to check open + closed PnL.
        AustinNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        585 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        340 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        552 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X