Trend Forge
Trend Forge is a fully configurable multi-trend strategy that lets you mix and match three independent trend indicators to define bullish and bearish market states. When all three trends align above price, the strategy enters long; when all three align below, it enters short. Every position is protected by an ATR-based stop loss, and trades close automatically when the trend alignment breaks down.
This script was converted from the original Bear & Bull Builder indicator I published into a back testable strategy with real entries, exits, and stop loss orders. It gives you access to TradingView's full Strategy Tester including equity curves, trade lists, and performance metrics.
How It Works
Trend Selection:
You choose three trend indicators independently, each with its own type and length:
- Trend 1 (default: EMA 21) — fast trend
- Trend 2 (default: EMA 55) — medium trend
- Trend 3 (default: SMA 89) — slow trend
Each trend slot supports five indicator types: EMA, SMA, RSI, CCI, and WaveTrend (WT). This gives you complete freedom to build a trend-following system tailored to your instrument and timeframe.
Entry Logic
Long Entry: Triggered on the first confirmed bar where price closes above all three trend values. The strategy enters long at market and simultaneously places an ATR-based stop loss order.
Short Entry: Triggered on the first confirmed bar where price closes below all three trend values. The strategy enters short at market with an ATR-based stop loss.
Stop Loss Calculation
The stop loss distance is calculated as:
`Stop Loss Distance = ATR(20) × Multiplier`
- For longs, the stop is placed below the highest of the three trend values at entry.
- For shorts, the stop is placed above the lowest of the three trend values at entry.
The ATR multiplier is user-adjustable (default: 2.5), letting you widen or tighten risk per trade based on volatility.
Exit Logic
Positions close via market order when the trend alignment condition that triggered the entry is no longer met — i.e., when price crosses back through one or more of the trend lines. If the stop loss is hit first, the strategy exits at the stop price instead.
---
Visual Features
All of the original indicator's visual overlays are preserved:
-Stop Loss Zones — shaded red regions between the entry level and the ATR stop loss, shown for longs and/or shorts (toggle on/off).
- Trend Zones — green-shaded areas that highlight when a bullish or bearish state is active.
- Signal-to-Order Fill Zones — a green zone that visualizes the one-bar delay between signal generation (bar close confirmation) and order execution (next bar open).
- Entry, Stop, and Exit Labels — price labels printed on the chart at entry, stop loss, and exit points with color coding (green = entry, orange = stop, cyan = exit). Toggleable for longs and shorts independently.
---
Settings Reference
| Group | Setting | Default | Description |
|-------|---------|---------|-------------|
| First Trend** | Trend Type | EMA | Indicator type for Trend 1 |
| First Trend** | Trend Length | 21 | Lookback period for Trend 1 |
| Second Trend | Trend 2 | EMA | Indicator type for Trend 2 |
| Second Trend | Trend Length | 55 | Lookback period for Trend 2 |
| Third Trend | Trend 3 | SMA | Indicator type for Trend 3 |
| Third Trend| Trend Length | 89 | Lookback period for Trend 3 |
| Stop Loss | ATR Multiplier | 2.5 | Multiplied by ATR(20) to set stop distance |
| Display | Long/Short Labels | Long on | Show entry, stop, and exit price labels |
| Display| Stop Loss Zones | Long on | Shade the region between entry and stop |
| Display | Trend Zones | Long on | Shade active bull/bear trend areas |
| Display | Signal-to-Order Zones | Long on | Show the fill delay visualization |
---
Strategy Properties
| Property | Value |
|----------|-------|
| Default Qty Type | 100% of equity |
| Initial Capital | 10,000 |
| Pyramiding | 0 (no stacking) |
| Order Fill | Next bar open |
| Bar Confirmation | Orders only on confirmed bars |
---
Usage Tips
- Start with the default EMA 21 / EMA 55 / SMA 89 combination and adjust from there.
- Pair faster trend lengths for scalping on lower timeframes, or slower lengths for swing trading on daily/weekly charts.
- Increase the ATR multiplier on volatile instruments to avoid premature stop outs; decrease it on stable instruments for tighter risk control.
- Use the Strategy Tester tab to compare different trend type and length combinations across your chosen symbol and timeframe.
- The WaveTrend and CCI options can provide earlier signals in ranging markets but may generate more whipsaws — backtest before committing.
---
Disclaimer
This strategy is provided for educational and backtesting purposes only. Past performance does not guarantee future results. Always validate with out-of-sample data and proper risk management before trading live capital.
Strategia Pine Script®

