Why stop loss did not trigger?
Author: jgimene1
Creation Date: 3/3/2021 8:31 PM
profile picture

jgimene1

#1
I am using a simple sell at close, condition, active position is older than a number or bars OR sell at stop loss 3%.

Most backtest trades on AAPL seem right but I came across this one attached with a 3.84% loss which should be only 3% (8/4/15 entry 29.36, 3% stop at 28.48 was hit at entry bar but the system shows the position closed on next bar at 28.24).

See attached.

Can you explain why this happened?

Thanks.
profile picture

Cone

#2
Price opened below the stop loss so you exited at the market open (gap down).
profile picture

jgimene1

#3
I understand the market down (gap down) concept but the stop at 28.48 was hit at the entry bar (low of 28.31 with a 3.21% change per data on screen) and should have closed the position on that same day with a 3% loss
profile picture

Eugene

#4
That black screen is making things harder to see and so does the absence of strategy's Rules but apparently you're questioning the lack of stop loss triggering on the bar of entry. Is this true? The Rule Wizard doesn't facilitate same bar exits though it can be reached in code. However, not knowing your entry Rules makes me wonder if it's a Stop/Limit entry too? If this is the case (I'm not assuming it is) then it shouldn't be approached because of this:

FAQ | Strategies and WealthScript > I want to test a strategy that buys and sells with stop/limit orders on the same bar.
profile picture

jgimene1

#5
Attached white screen. Yes, the issue is the lack of stop loss triggering on the bar of entry. I use sell at stop loss (3%). I checked your link but it is too complicated if I have to add code as i do not know how to code. I tried the intraday rules but it does not work, Can you send the code to add and where?
profile picture

Cone

#6
We resolved this for John a ticket.

The Strategy Builder will never give you a same-bar exit; these need to be coded manually. Generally, it's only "legal" to add a stop loss on the entry bar if the entry was a market order.

For example, here's some basic code with no entry bar protection.

CODE:
Please log in to see this code.


And here's the same code with entry bar protection (for the backtest):

CODE:
Please log in to see this code.


I said, "for the backtest" because you will not get an Alert to exit a Position before you actually buy it. You have to know to enter the stop order after you buy the position with your broker.
profile picture

jgimene1

#7
Thanks, Cone, working fine now.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).