OPEN-SOURCE SCRIPT
BB Mean Reversion Long + SL

This strategy exploits statistical price extremes using Bollinger Bands
on a mean reversion logic — when price closes below the lower band,
it's statistically outside 95% of normal price action.
That's the entry. The target is simple : get back to the mean.
━━━ LOGIC ━━━
- Entry → price closes below the lower band (crossunder)
- Take Profit → price returns to the SMA (middle band)
- Stop Loss → fixed % below entry price
━━━ SETTINGS ━━━
- SMA Period (N) → default 20
- Standard Deviations (K) → default 2.0
- Stop Loss % → default 1.5%
- Pyramiding → up to 3 simultaneous entries
━━━ BEST TIMEFRAME ━━━
Tested and works best between 45min and 2h.
Below 30min : too much noise.
Above 2h : price extremes often reflect real trend, not overreaction.
━━━ NOTES ━━━
→ Designed for mean-reverting assets with clear volatility cycles
→ Works particularly well on XAUUSD, indices ETFs
→ Avoid running during major news events (NFP, CPI, Fed)
→ Not recommended to hold positions over the weekend
→ qty is set to fixed lot — adjust to your broker's lot size
Tune N and K to your asset. Default settings are a starting point,
not a final answer. The edge is in the calibration.
on a mean reversion logic — when price closes below the lower band,
it's statistically outside 95% of normal price action.
That's the entry. The target is simple : get back to the mean.
━━━ LOGIC ━━━
- Entry → price closes below the lower band (crossunder)
- Take Profit → price returns to the SMA (middle band)
- Stop Loss → fixed % below entry price
━━━ SETTINGS ━━━
- SMA Period (N) → default 20
- Standard Deviations (K) → default 2.0
- Stop Loss % → default 1.5%
- Pyramiding → up to 3 simultaneous entries
━━━ BEST TIMEFRAME ━━━
Tested and works best between 45min and 2h.
Below 30min : too much noise.
Above 2h : price extremes often reflect real trend, not overreaction.
━━━ NOTES ━━━
→ Designed for mean-reverting assets with clear volatility cycles
→ Works particularly well on XAUUSD, indices ETFs
→ Avoid running during major news events (NFP, CPI, Fed)
→ Not recommended to hold positions over the weekend
→ qty is set to fixed lot — adjust to your broker's lot size
Tune N and K to your asset. Default settings are a starting point,
not a final answer. The edge is in the calibration.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。