Signal Examples
This page showcases realistic and powerful signal examples built with the StockBeat DSL.
The goal is to demonstrate how simple primitives compose into professional-grade trading logic.
All examples are written exactly as users would define them in StockBeat.
1. RSI Oversold Bounce (Classic Mean Reversion)
Idea:
Enter when RSI becomes oversold and starts recovering.
close().rsi(14).below(30).held_for(3)
Explanation:
- RSI(14) drops below 30
- Condition holds for 3 consecutive bars
- Filters out single-bar spikes
Use case:
Mean-reversion strategies in range-bound markets.
2. Moving Average Crossover (Trend Following)
Idea:
Detect when short-term momentum overtakes long-term trend.
close().ema(9).crosses_above(close().ema(21))
Explanation:
- Fast EMA crosses above slow EMA
- Evaluated only at the crossing point
Use case:
Trend entry confirmation.
3. Momentum + Trend Confirmation
Idea: Only enter when momentum and trend agree.
close().ema(9).crosses_above(close().ema(21))
.and(close().rsi(14).above(50))
Explanation:
- Crossover confirms trend
- RSI above 50 confirms bullish momentum
Use case: Avoid false breakouts.
4. Volatility Expansion Breakout
Idea: Trade breakouts only when volatility expands.
close().crosses_above(close().bb(20, 2, up))
.and(close().bb(20, 2, avg).rising(5))
Explanation:
- Price breaks above upper Bollinger Band
- Band width rising → volatility expansion
Use case: Breakout strategies with volatility filter.
5. MACD Reversal After Consolidation
Idea: Wait for MACD signal after a quiet period.
close().macd(12, 26, 9).gt(0).within(3)
Explanation:
- Histogram crosses above zero
- Signal must occur within last 3 bars
Use case: Early trend reversals.
6. Multi-Condition Entry With Time Constraint
Idea: Require confirmation within a time window.
close().ema(9).crosses_above(ema(21))
.and(close().rsi(14).above(50).within(2))
Explanation:
- RSI confirmation must happen within 2 bars of crossover
- Prevents late entries
Use case: Tighter execution rules.
7. Failed Breakout (Contrarian Setup)
Idea: Detect failed breakout and fade the move.
close().crosses_above(close().ema(50))
.and(close().lt(close().ema(50)).within(2))
Explanation:
- Price breaks resistance
- Quickly falls back below → failure
Use case: False breakout detection.
8. Trend Exhaustion Warning
Idea: Strong trend losing momentum.
close().rsi(14).falling(5)
.and(close().gt(close().sma(200)))
Explanation:
- RSI falling for 5 bars
- Price still above long-term trend
Use case: Prepare exits or tighten stops.
9. Signal With Explicit Negation
Idea: Enter trend-following trades only when momentum is strong and the market is not in an expansionary (high-volatility) phase, reducing the risk of false breakouts and whipsaws.
close().ema(9).crosses_above(ema(21))
.and(close().rsi(14).above(50))
.and(close().ema(5).sub(close().ema(20)).rising(3).not())
Explanation:
- Avoid entries during abnormal volatility
Use case: Risk control.
10. Persistent Trend Confirmation Alarm
Idea: Detect a sustained trend shift confirmed by momentum, avoiding short-lived spikes and noisy crossovers.
close().ema(9).crosses_above(close().ema(21))
.and(close().rsi(14).above(55)).held_for(2)
Explanation:
- Combines short-term and medium-term EMA crossover to identify trend direction
- RSI threshold confirms momentum strength
held_for(2)requires the condition to persist across multiple bars, filtering out transient signals
Use Case: Robust alerts suitable for live monitoring and automated notification workflows.
