Understand the Jesse Strategy Execution Model
masterJesse executes strategy logic once per candle, after the candle has closed. The sequence is:
before()runs.- If a position is open:
update_position()runs (used for managing stops/targets or liquidating). - If no position is open:
- If entry orders are pending:
should_cancel_entry()is checked. IfTrue, pending orders are cancelled. - If no orders are pending:
should_long()andshould_short()are checked. If they pass,go_long()orgo_short()are called to setself.buyorself.sell. Iffilters()are defined, they must all pass before orders are submitted.
- If entry orders are pending:
after()runs.update_chart()runs (after completed candles in backtests, or ~once per second on forming candles in live/paper sessions).
Note: should_long, should_short, and should_cancel_entry are not called while a position is open; only update_position runs in that state.