Need help with stoploss and max loss per day

Hello for some reason no matter what i do stoploss is not working and same is the case with daily max loss

Calculate = Calculate.OnEachTick;
            IsOverlay = true;
        }
        else if (State == State.Configure)
        {
            TraceOrders = true;
            SetStopLoss("LongEntry", CalculationMode.Currency, 40, false);
            SetStopLoss("ShortEntry", CalculationMode.Currency, 40, false);
            // Optional:
            // SetProfitTarget("LongEntry", CalculationMode.Ticks, 20);
            // SetProfitTarget("ShortEntry", CalculationMode.Ticks, 20);
        }
    }

    protected override void OnBarUpdate()
    {
        if (CurrentBar < 60) return;

        if (Bars.IsFirstBarOfSession && IsFirstTickOfBar)
        {
            dailyLockoutTriggered = false;
            Print("πŸ”„ New session started.");
        }

        double cumProfit = SystemPerformance.AllTrades.CumProfit;
        Print("πŸ“Š Daily CumProfit = " + Math.Round(cumProfit, 2));
        if (cumProfit < dailyLossThreshold)
        {
            dailyLockoutTriggered = true;
            Print("🚨 Daily loss limit breached.");
        }

I want to be able to close order if loss = 40$ and also stop trading for the day if total loss is = or > than 100.

Is anyone able to help pls.

sai

You can set max stop loss from the account settings at ninjatrader.com. This is better than what you’re coding up.