A backtest also copies how orders are handled.
When the entry and the stop land together
With a limit entry, you can ask Wildflower to give up on it if price reaches your stop first.
For a buy, your limit sits above your stop. So price cannot reach the stop without passing the limit first. The order fills, and hitting the stop after that is an ordinary losing trade. The order is only cancelled when the limit sits beyond the stop.
A blocked waiting order does not fill later at its old price
Wildflower holds one position at a time, so a waiting entry order cannot fill while another trade is open.
The backtest treats that order as stood down. It fills only once price comes back to its level, as a real waiting order at your broker would. It never fills at a price the market has already left. If price has already passed a stop order's level, Wildflower enters at market instead, but never while another trade is open.
On an account running more than one strategy, the one-position rule covers them all:
- The moment one strategy enters, Wildflower withdraws every other strategy's waiting order from your broker, so a second position can never open.
- A signal that arrives during that trade is refused. Each strategy takes its next signal once your account is flat (holds no position).
- A withdrawn waiting order whose time has not run out is placed again once you are flat, at its own level.
A waiting order only holds your account once it fills. Until then, another strategy may enter, which withdraws it as above.
A waiting order is cancelled at your broker at the close of the last candle it was allowed to wait, never later.
Live only enters through an order that is really working at your broker. If the prices say a waiting order filled but no order of yours was there, live records the refusal. It never buys or sells at market to catch up.
The candle your entry filled in counts from your fill
The seconds before your fill are not part of your trade. So on that candle, your target only counts what happened after the fill. Your stop is not affected: price must pass your entry to reach it.
At a close, your stop and target come first
If your firm sets a time every account must be flat by, Wildflower closes positions and cancels waiting entries two minutes before it.
At that time, and at the daily close, your stop and target are checked first. A trade that reached one of them leaves there.
When the price history has a hole in it
Sometimes the stored prices miss a stretch while the market was open. If that happens mid-trade, the backtest closes the trade at the last known price. It marks the trade "the price history stopped mid-trade" instead of making up a price.
Live trading is not affected, because your stop and target are real orders at your broker. The trade is left out of the agreement score. A gap across the daily close also ends the trade at the last price before the gap, never at the next session's first price.
The same goes for entries. A market entry is priced at the first price after your signal, but only when the history has the minute after it. If that minute is missing, the entry is priced at the signal's own price. It never reaches across the gap to when prices come back, which could be days later or on a different contract.
That fallback price must be one the entry's own minute really traded. A signal from a longer candle can come from a price several minutes earlier. If the entry minute never traded at that price, the entry moves to the nearest price it did trade.
What can go wrong
Backtests and live can still differ where a live-only rule refuses a trade, such as a news window, an exchange close or a daily cap. Then live takes fewer trades.