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.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.