In addition to @Grahal comments.
I don’t know if this is a similar problems I found on some other code I was looking at but…
When the code is run, and an order entry condition is true, it’s not till the start of the next bar that the order is executed. Till then, the ‘NEW’ calculated Stoploss and target are still invalid even though there code line have been run.
I think the entry order is first executed before the new stop and targets can be set.
However, till then, the old stop and targets values may still be valid till overwritten by the new values.
But when the new entry is made, if the previous stop/target fall such that their values are triggered, the trade is exited at the same entry price as it tried to enter.
This exit means that the newly calculated stop/target values never becomes valid orders, and never overwrite the prior valid values and all valid entries that follow execute the same way.
Until the price changes to a value which removes this instant exit, the new stop and target will then become the new valid ones, and the cycle repeats.
Though I can’t tell directly from the image if this is the same thing, it looks like it, It wouldn’t surprise if the entry/exit is the same value. Also the last valid trade was a long with its stop below entry, which was hit, and the following 3 short trades look like their entries are above that’s valid trades stop level, so if these try to enter, this valid prior stop is already being hit, because the stop level is below the entry level for the short.
If nothing else changes this situation, the next valid trade will possible be a long entry above the last valid stop, ( long stop below entry level) a short entry below the last valid stop s(short stop above entry level) , if i’m right!