- ago
I'm running into an issue where the strategy doesn't seem to capture the same-bar trailing stop loss until the next bar.

Here's an example. On this position, UTSL, the ETF jumped at the open and then fell back a bit to trigger the trailing s/l in my account (I trade these manually, but I captured the s/l percentage correctly in the order). However, the strategy didn't recognize the trade, and since the stock recovered in the bar it says I should still be in the position.

I created this code using the building block tool.

Entry: $35.59
Bar high: $37.66
Bar low: $36.85
Trailing stop loss (same bar): 2%
Exit: $36.91

0
127
3 Replies

Reply

Bookmark

Sort
Cone8
 ( 4.92% )
- ago
#1
That's how all orders work for both backtests and live trading. When a bar is complete signals create orders that are active for the next bar. If you need orders to trigger more quickly, use smaller intervals.

Exception:
When an order is filled while Auto-Trading, a strategy can implement "same-bar" Stop and/or Limit orders (for the entry bar only).
See AssignAutoStopTargetPrices in the QuickRef.
0
- ago
#2
Thanks, Cone. Then what's the difference between "same-bar" and not? I assumed same-bar meant the system would send the signal to trade at the s/l level if it's hit at any point within the bar.
0
Cone8
 ( 4.92% )
- ago
#3
Because it's an event-driven action.
If the strategy already knows where it's going to place stop and limit orders when the entry order fills, the Order Manager can use those prices to immediately place those orders. See the QuickRef for more discussion about that.

Otherwise, the next "event" is the end of the next bar - i.e., when the strategy runs next.
0

Reply

Bookmark

Sort