There is not a way to detect a stop loss specifically has filled in the Strategy Builder, but this can be coded into an unlocked script.
In the Strategy Builder you can check that the position was exited, but this could be from any exit order such as a profit target, or market order.
In the Strategy Builder Condition Builder, in the condition set for the entry:
Select Misc > 'Bars since exit', in the center select Greater, on the right select Misc > Numeric value (leave this set to 0 meaning an exit has occurred at least once).
In an unlocked script implement the OnOrderUpdate() override. Check the order.Name is equal to "Stop loss" and that the order.OrderState is OrderState.Filled.
Set a bool to disable new trades.
Consider the simplified example below.
In the scope of the strategy class:
private bool disableTrading;
if (disableTrading == false /* && entry conditions here)
{
EnterLong();
}
protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string comment)
{
if (order.Name == "Stop loss" && order.OrderState == OrderState.Filled)
{
disableTrading = true;
}
}

Comment