blog

Rule-Based Trading Alerts: Custom Automated App Build Guide

By khurram June 24, 2026 17 min read
 

A rule-based trading alerts built around rule-based alerts and order automation sits in a practical middle ground between fully manual trading and black-box algorithmic systems. It lets traders codify their strategies into explicit, auditable rules – if RSI drops below 30 and volume is above the 20-day average, generate a buy alert – and optionally automate order placement when those rules fire, while retaining full visibility and control over every decision the system makes. This article covers how to architect and build a custom automated trading app with a rule engine, alert system, and order automation layer that is reliable, testable, and extensible.

rule-based trading alerts: Rule Engine Architecture

The rule engine is the heart of a custom automated trading app. It evaluates market conditions against trader-defined rules on a schedule or in response to market data events, and produces signals that drive alerts or automated orders.

Designing a Flexible Rule DSL

A rule in a custom automated trading app is a logical expression over market data indicators that evaluates to true or false. A well-designed rule domain-specific language (DSL) lets traders express rules at a high level – ‘RSI(14) crosses below 30 and Volume(1d) exceeds MA(Volume, 20)’ – without writing Python. Represent rules as structured JSON or a simple expression tree: each node is an operator (AND, OR, NOT), a comparison (GREATER_THAN, LESS_THAN, CROSSES_ABOVE, CROSSES_BELOW), or a leaf value (an indicator name and its parameters). Store rules in the database as serialised expression trees. The rule evaluator traverses the tree, resolving indicator values from the current market data feed at each leaf, and returns a boolean result. This representation is language-agnostic, inspectable, and allows rules to be built via a UI form rather than requiring traders to write code. For traders who want code-level flexibility, offer a Python expression mode where the rule is a Python lambda evaluated in a sandboxed environment.

Technical Indicators in a rule-based trading alerts

The indicator library is the vocabulary of the rule DSL. Implement indicators as Python functions that take a price/volume series and parameters and return a scalar or series. The pandas-ta and TA-Lib libraries provide implementations of the standard technical indicators (RSI, MACD, Bollinger Bands, ATR, EMA, SMA, VWAP, Stochastic) that cover most rule-based trading strategies. Wrap these in a consistent interface – indicator_name(symbol, timeframe, period, lookback_bars) – so the rule evaluator can resolve any indicator generically without special-casing each one. Cache indicator values in Redis with a TTL matching the indicator’s timeframe – a 1-hour MACD does not need to be recomputed on every market data tick, only when a new 1-hour bar closes. Cache invalidation on bar close events keeps indicator values current without unnecessary recomputation.

Rule Evaluation Scheduling and rule-based trading alerts Triggers

Rule evaluation can be triggered by time (evaluate all rules at bar close), by price events (evaluate rules when price moves beyond a threshold), or continuously (evaluate rules on every market data tick). Bar-close triggered evaluation is the simplest and most appropriate for daily, hourly, or 15-minute rules – Celery Beat schedules rule evaluation at each bar close time for each active symbol. Tick-triggered evaluation is necessary for intraday strategies where the rule condition can be satisfied mid-bar – a price crosses a threshold, for example. Implement tick-triggered evaluation as a WebSocket subscriber that receives price updates and evaluates the relevant rules on each tick. Batch rule evaluations by symbol to minimise redundant indicator computations – all rules for a given symbol are evaluated together, computing each indicator once regardless of how many rules reference it.

Alert System Design and Delivery

When a rule fires, the alert system delivers a notification to the trader and optionally triggers the order automation layer. Alert design has significant impact on whether traders act on signals effectively.

Alert Delivery Channels

A custom automated trading app should support multiple alert delivery channels because traders are not always looking at the app interface. Email alerts are the baseline – they provide a persistent record and reach traders on any device. Push notifications via a mobile app or browser push are better for time-sensitive signals where seconds matter. Webhook delivery allows integration with external tools: a webhook to a Telegram bot, Slack channel, or Discord server gives traders alerts in the platforms they already use. SMS via Twilio provides high-reliability delivery for critical alerts when other channels may be missed. Implement alert delivery as a Celery task that fans out to all configured channels concurrently – the alert should arrive across all channels within five seconds of the rule firing. Store each alert with its delivery status per channel, retry failed deliveries, and flag alerts where all delivery attempts failed so traders can see missed signals.

Alert Content and Actionability

An alert that simply says ‘Rule fired on AAPL’ is not actionable. The alert content should include: the rule name and description, the symbol and current price at the time of the alert, the indicator values that triggered the rule, the suggested action (buy, sell, close position), the suggested position size based on the configured risk parameters, and a deep link back to the app for one-click order placement review. Rich alert content – including a mini chart showing the price action and indicator values at the time of the signal – significantly improves the trader’s ability to act on the alert quickly and correctly. For email alerts, embed the chart as an inline image generated server-side using matplotlib or plotly. For push notifications where rich content is constrained, include the key numbers (price, indicator values, suggested size) in the notification text and surface the full detail in the app on tap.

rule-based trading alerts rule engine and alert delivery system architecture
rule-based trading alerts rule engine and alert delivery system architecture

Order Automation Layer

Order automation in a custom automated trading app translates rule signals into broker orders without requiring manual intervention. The automation layer must be reliable, auditable, and bounded by risk controls that prevent runaway automated trading.

Order Generation from Rule Signals

When a rule fires with order automation enabled, the automation layer computes the order parameters – symbol, direction, order type, quantity, and price – from the signal and the trader’s configured position sizing rules. Position sizing is computed from account equity and risk parameters: ‘risk 1% of account equity per trade, stop loss at 2 ATR from entry’. This gives a position size in shares or contracts that is consistent with the trader’s risk management framework regardless of price level. Generate market orders for signals where execution speed is paramount, limit orders at a specified offset from the current mid-price for signals where fill price matters, and bracket orders (entry with attached stop-loss and take-profit) for strategies with defined risk/reward targets. Store each generated order as an AutomatedOrder record with the rule that triggered it, the signal parameters, the computed order parameters, and the current status (pending approval, submitted, filled, rejected, cancelled).

Human Review Gates in rule-based trading alerts

Fully automated order placement – the system places orders without any human review – is appropriate for strategies that have been thoroughly tested and validated, and for traders who have deliberate confidence in the automation. For strategies under development, or for traders who want oversight without manual order entry, implement a human review gate: the automation layer generates the order and queues it for trader approval, sending an alert with an approve or reject action. The trader approves via a mobile push notification tap, a web dashboard button, or a webhook response within a configurable timeout. If no approval is received within the timeout, the order is cancelled. This semi-automated mode gives traders the efficiency of automated order generation with the safety of human review, and is the recommended starting mode for any new automated strategy.

Broker API Integration for Order Automation

The order automation layer connects to broker APIs to submit and manage orders. Broker API integration is where custom automated trading apps most frequently encounter reliability and compliance challenges.

Supported Broker APIs and Abstraction Layer

Interactive Brokers (TWS API and IB Gateway) is the most versatile option for custom automated trading apps, supporting equities, options, futures, forex, and bonds across global markets from a single API. Alpaca provides a clean REST API for US equities and crypto with commission-free trading and good paper trading support. For UK and European retail traders, IG Group and Saxo Bank both provide APIs for CFDs, forex, and equities. Build a broker abstraction layer – a Python abstract base class with methods for submit_order, cancel_order, get_position, and get_account – so that the automation logic is broker-agnostic. Each broker implements the abstraction with its specific API calls. This makes it practical to support multiple brokers, add new brokers without changing automation logic, and test the automation layer against a paper trading broker before connecting to a live account.

Order State Management and Reconciliation

Order state management in a custom automated trading app must handle the full lifecycle of an order: submitted, acknowledged, partially filled, fully filled, cancelled, and rejected. Subscribe to broker order status events via WebSocket or poll the broker API every few seconds to track order state changes. Reconcile the app’s internal order state with the broker’s record on each startup and after any connectivity interruption – gaps between the app’s view and the broker’s view are a safety-critical issue in automated trading. Implement a daily reconciliation job that compares the app’s position records with the broker’s reported positions and flags discrepancies for manual review. An automated trading app that does not know its actual position state cannot safely generate new orders – always verify position state before submitting orders in a new session.

Backtesting and Strategy Validation

A custom automated trading app should include backtesting capability so traders can evaluate rule performance on historical data before enabling live order automation.

Backtesting Rule-Based Strategies

Backtest the rule engine against historical OHLCV data by replaying bar-by-bar and evaluating rules at each bar close, simulating the same logic that runs in production. Compute indicator values from the historical data series rather than from a live market feed, using the same indicator functions as production to ensure consistency between backtest and live results. Apply realistic transaction cost assumptions – commission per trade, estimated bid-ask spread, slippage as a percentage of order size – to avoid overstating backtest returns. Report standard performance metrics: total return, annualised return, Sharpe ratio, maximum drawdown, win rate, average win/loss ratio, and number of trades. Visualise the equity curve and drawdown series so traders can see the strategy’s behaviour through different market conditions, not just the headline return. Walk-forward validation – training the rule parameters on one period and testing on the next – is the minimum validation standard before enabling live automation for any strategy.

rule-based trading alerts backtesting and order automation workflow
rule-based trading alerts backtesting and order automation workflow

Risk Controls and Safety Features

Automated order placement without robust risk controls is a liability. These safety features are non-negotiable in any production custom automated trading app.

Pre-Trade Risk Checks for rule-based trading alerts

Every automated order must pass a pre-trade risk check before being submitted to the broker. Minimum checks: maximum order size (reject orders above a configurable notional value); maximum daily loss (halt all automation if the day’s realised and unrealised loss exceeds a threshold); maximum open positions (prevent automation from opening more concurrent positions than the risk framework allows); duplicate order detection (prevent the same signal from generating multiple orders within a short window); and market hours check (reject orders outside the market session for the relevant instrument). Implement the pre-trade checks as a synchronous gate that all automated orders pass through before submission – a check that fails must block the order, not log a warning and proceed. Log every check failure with the order details and the reason for rejection, so traders can review near-misses and adjust risk parameters accordingly.

Kill Switch and Emergency Controls

A manual kill switch that immediately halts all automation and cancels all open orders is an essential safety feature of any custom automated trading app. Implement the kill switch as a prominent control in the app dashboard, accessible with a single action and requiring no confirmation (speed matters in an emergency). The kill switch should also be accessible via a mobile push notification action and via a webhook endpoint, so traders can activate it from anywhere without opening the app. Store the kill switch state in Redis (for fast reads by the automation layer) and the database (for audit trail). Every automated order generation step checks the kill switch state before proceeding – if the kill switch is active, no new orders are generated regardless of rule signals. Test the kill switch explicitly as part of system testing before going live with order automation.

rule-based trading alerts: Pros and Cons

Pros

  • Strategy transparency – rule-based automation produces explicit, auditable logic that traders understand and can explain, unlike black-box ML models whose decisions may be opaque.
  • Consistent execution – automated order placement removes emotional hesitation and execution inconsistency, ensuring the strategy is executed as designed on every signal.
  • Custom fit to strategy – a custom app models the trader’s specific rules, risk parameters, and workflow rather than forcing the strategy into a commercial platform’s constraints.
  • Broker flexibility – a custom abstraction layer supports multiple brokers and allows switching without rebuilding the strategy logic.

Cons

  • Development and maintenance responsibility – the trader or their development partner owns the reliability, correctness, and security of the system, which requires ongoing engineering attention.
  • Rule-based limitations – explicit rules cannot capture all market dynamics; strategies that require nuanced pattern recognition or market context beyond indicator values may need ML augmentation.
  • Infrastructure cost – a production automated trading app requires always-on infrastructure (server, database, message broker, market data feed) with associated hosting and data costs.

Frequently Asked Questions: rule-based trading alerts

How much does it cost to build a rule-based trading alerts?

A production-ready custom automated trading app with a rule engine, alert system, order automation, backtesting, and broker API integration typically costs GBP 40,000 to GBP 90,000 to build from scratch, depending on the number of brokers integrated, the complexity of the rule DSL, the sophistication of the UI, and the market data infrastructure required. A simpler version – rule evaluation, email alerts, and semi-automated order placement for a single broker via a command-line or basic web interface – can be built for GBP 15,000 to GBP 30,000. Ongoing costs include hosting (GBP 100 to GBP 400 per month for a production-grade server environment), market data subscriptions (GBP 50 to GBP 500 per month depending on data quality and coverage), and maintenance for updates and broker API changes. For traders who want custom functionality but at lower cost than a full custom build, some commercial algorithmic trading platforms (TradingView Pine Script with broker integration, Trality, QuantConnect) offer configurable rule-based automation without the development investment, at the cost of less flexibility and vendor dependency.

What is the regulatory status of rule-based trading alerts in the UK?

Building and operating a custom automated trading app for personal trading in the UK does not require FCA authorisation – individuals are permitted to automate their own investment decisions without regulatory oversight. Operating an automated trading app on behalf of others – managing client money or providing algorithmic trading signals as a service – requires FCA authorisation as an investment manager or investment adviser. For institutional traders and professional firms, the FCA’s MAR (Market Abuse Regulation) and the EU’s MiFID II algorithmic trading rules (which the UK retained post-Brexit as onshored legislation) impose requirements on algorithmic trading systems including testing, kill switches, and audit trails. Individual retail traders using a custom app for their own account are not subject to these institutional requirements, but implementing the same kill switch, audit trail, and risk control features is good practice regardless of regulatory obligation.

How do you prevent a bug in the rule engine from generating erroneous orders?

Preventing bugs from generating erroneous orders requires defence in depth across development and runtime. Development-time: comprehensive unit tests for every rule evaluator function, every indicator computation, and every order generation path; mandatory code review for all changes to the rule engine and order automation code; paper trading environment for testing new rules and strategy changes before enabling live automation. Runtime: pre-trade risk checks that catch orders outside normal parameters (order size too large, price too far from market, duplicate signals); a human review gate for new or modified strategies during the validation period; and the kill switch that any team member can activate immediately. The most dangerous bugs are those that generate orders in the right direction but at the wrong size or price – size checks (maximum order notional) and price reasonableness checks (maximum deviation from current market price) catch these specifically. Test the edge cases explicitly: what happens if the market data feed returns a null value for an indicator? What if the broker API returns an error? What if the position state is stale? Handling these edge cases correctly is what separates a production-grade custom automated trading app from a script that works in normal conditions.

Can a rule-based trading alerts work with multiple timeframes?

Multi-timeframe analysis – using higher-timeframe context to filter or confirm lower-timeframe signals – is a common and effective trading approach that a custom automated trading app should support. Implement multi-timeframe rules by allowing indicator references to specify their timeframe explicitly: RSI(14, ‘1d’) for the daily RSI and RSI(14, ‘1h’) for the hourly RSI. The indicator cache stores values keyed by symbol, indicator name, parameters, and timeframe, so multi-timeframe rules resolve indicator values independently per timeframe. A rule like ‘RSI(14, 1h) below 35 AND RSI(14, 1d) below 50 AND price above SMA(200, 1d)’ filters for oversold conditions on the hourly timeframe that occur within a broader bearish context on the daily timeframe, but above the long-term trend. Multi-timeframe rules require data for all referenced timeframes to be available and current at evaluation time – ensure the market data ingestion pipeline and indicator cache cover all timeframes used in active rules before scheduling rule evaluation.

Conclusion

A custom automated trading app built around a rule engine, alert system, and order automation layer gives traders the tools to execute their strategies consistently, at speed, and with full auditability. The architecture described here – a flexible rule DSL with a structured expression tree representation, indicator caching in Redis, multi-channel alert delivery, order automation with human review gates, and pre-trade risk controls – is the foundation of a production-grade system that is reliable enough to trust with real capital. Getting the safety features right – pre-trade checks, kill switch, reconciliation – is as important as getting the strategy logic right. A trading app that executes the strategy correctly but fails unsafely under error conditions is not production-ready.

Building a custom automated trading app and want a development team that understands both the software engineering and the trading domain requirements? At Lycore, we have built trading platforms, rule-based alert systems, and order automation tools for retail traders, prop trading firms, and investment managers across the UK and Europe – with broker API integrations, backtesting frameworks, and the risk controls that production trading systems require. Talk to our trading software development team about your project.