Learn › Automation

Signals, Alerts and Automated Execution: Separating the Pieces Safely

An automated trading setup has two distinct jobs. One part decides what should happen — a signal such as "go long", "move the stop" or "exit". The other part makes it happen at a broker — placing, modifying and cancelling orders. Treating these as separate components makes a system easier to test, safer to run and easier to switch between alert-only and live modes.

Signal-only, paper and live

  • Signal-only (alerts): the strategy produces signals and notifications, but no order is ever sent. This is useful for discretionary traders who want a second pair of eyes, and for evaluating a strategy in real time without any execution risk.
  • Paper: signals are executed on a simulated broker account. This tests the full order lifecycle without risking money (see paper trading to live).
  • Live: signals are executed on a real account.

A clear mode per strategy, enforced by the execution layer rather than by convention, prevents a strategy intended for alerts from ever reaching a broker.

Safeguard 1: idempotency

Signals can be delivered more than once — a webhook retried after a timeout, a restart that replays the last bar, a network glitch. If every delivery places an order, a single signal can open two or three positions. An idempotent system gives each signal a unique identity and processes it at most once, so duplicates are recognised and ignored.

Safeguard 2: reconciliation

The broker, not your software, is the source of truth for positions and orders. A robust system regularly compares its own view with the broker's and acts on differences:

  • A position at the broker that the system does not know about should be adopted or flagged, not ignored.
  • A position the system thinks is open but the broker shows as flat (for example after a broker square-off or a manual exit) should be closed in the system's records.
  • Exit orders left resting for a symbol that is now flat should be cancelled — the leftover-leg problem.

Safeguard 3: fail closed

When something is uncertain — market data is missing, a cancellation cannot be confirmed, the instrument cannot be resolved to a valid contract — the safe default is to do nothing new and alert a human, rather than guess. A system that "fails open" by using a fallback price from a different source or assuming an order was cancelled can turn a small data problem into a large trading loss.

Safeguard 4: separate market data from execution

The data used to generate signals and the broker used to execute them do not have to be the same provider, but the mapping between them must be exact. A symbol on a data feed must resolve to the correct tradable instrument at the broker — the right exchange, contract month, lot size and tick size. If that mapping cannot be verified, the order should be refused.

Safeguard 5: limits and permissions

  • Maximum position size and number of open positions per strategy and per account.
  • Minimum free margin or available-balance floors below which new entries are refused.
  • API keys with trading permission only — never withdrawal permission.
  • Restricting IP addresses for API keys where the broker supports it.

Safeguard 6: observability

Every signal, order, modification, rejection and cancellation should be logged with a timestamp and a reason — but never with secrets such as API keys, tokens or passwords. Alerts for rejections, unresolved states and unexpected positions mean problems are found in minutes rather than at the end of the day.

Restarts and deployments

Software has to be updated, and servers restart. On startup, an execution component should rebuild its view from the broker rather than from memory, re-adopt open positions, and avoid acting on stale signals. Planning updates outside market hours (see market hours from India) reduces risk further.

Key takeaways

  • Separate deciding (signals) from doing (execution), and make the mode explicit and enforced.
  • Process each signal once, reconcile with the broker continuously, and fail closed when uncertain.
  • Limit permissions, log without secrets, and alert on anything unexpected.

Educational content only. This guide explains general concepts and is not investment advice or a recommendation to trade any instrument. Trading involves substantial risk of loss, and historical or simulated results do not guarantee future performance. Read the Risk Disclosure.

Related guides