1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.
Source Code
92 lines of Pine Script v4 from bayesian/strategies/bbsmastrat.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.
Bayesian BBSMA Oscillator Strategy plots these breakout and breakdown probability lines as oscillators in a separate pane. Long entries trigger when the upward probability crosses down from maximum, while short entries trigger when downward probability drops from maximum. Trades are protected using a percentage-based trailing stop loss. Settings allow customization of Bollinger Band parameters, Bayesian lookback period, trailing stop percentages, start year, and directional long/short toggles.
Bayesian probability calculation for candle breakouts
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
BB SMA Period
int
20
bbSmaPeriod
BB Standard Deviation
float
2.5
bbStdDevMult
SMA Period
int
20
smaPeriod
Bayesian Lookback Period
int
20
bayesPeriod
Plot Next Candles Breaking Down?
bool
true
showNextCandleDown
Plot Next Candles Breaking Up?
bool
true
showNextCandleUp
Trail Long Loss (%)
float
4
longTrailPerc
Trail Short Loss (%)
float
4
shortTrailPerc
Year started
int
2019
startingYear
Calculate longs?
bool
true
doLongs
Calculate shorts?
bool
true
doShorts
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This strategy captures strong bullish momentum by combining a 200-period SMA baseline, a custom Bollinger Band, the True Strength Index (TSI) smoothed with WMAs, and the ADX trend strength indicator. It initiates long positions when price is above the 200 SMA,
This strategy combines an EMA ribbon with MACD confirmation and plots in a separate pane. It enters when ribbon alignment, optional MACD zero or signal crosses, volume, smart-money, and multi-timeframe filters agree, then exits with percentage stop loss and ta
This strategy combines Bollinger Bands, Bollinger Band Width, and the Relative Strength Index (RSI) for mean-reversion trades. It enters long when price crosses below the lower band with oversold RSI, or when band width contracts under low volatility. Short en
AwesomeADX is a Pine Script v4 strategy that combines an Awesome Oscillator, ADX directional movement, and Bollinger percent B with an optional four-length moving-average trend filter. It sizes each position as a percentage of equity and can limit trades to a
This strategy plots MACD line, signal line, Bollinger Bands, and RSI on the price chart. It signals long entries on MACD crossover above signal with RSI below 50 and price below BB basis, plus optional DMI filter. Short entries are available but disabled by de
This educational strategy demonstrates moving average crossovers filtered by RSI momentum, incorporating ATR-based risk management. It calculates a 10-period SMA, a 30-period SMA, a 14-period RSI, and a 14-period ATR. Long entries trigger when the fast SMA cro