BollingerBands Strat + pending order alerts via TradingConnector.pine
//@version=5
strategy("Bollinger Bands Strategy with alerts (incl. pending orders) via TradingConnector to Forex", overlay=true, default_qty_value=1000)
source = close
length = input.int(20, minval=1)
mult = input.float(2.0, minval=0.001, maxval=50)
basis = ta.sma(source, length)
dev = mult * ta.stdev(source, length)
upper = basis + dev
lower = basis - dev
buyEntry = ta.crossover(source, lower)
sellEntry = ta.crossunder(source, upper)
if (ta.crossover(source, lower))
strategy.entry("BBandLE", strategy.long, stop=lower, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandLE")
alert(message='long price='+str.tostring(lower), freq=alert.freq_once_per_bar_close)
else
strategy.cancel(id="BBandLE")
alert(message='cancel long', freq=alert.freq_once_per_bar_close)
if (ta.crossunder(source, upper))
strategy.entry("BBandSE", strategy.short, stop=upper, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandSE")
alert(message='short price='+str.tostring(upper), freq=alert.freq_once_per_bar_close)
else
strategy.cancel(id="BBandSE")
alert(message='cancel short', freq=alert.freq_once_per_bar_close)
//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)
//Lines of code added to the original built-in script: 14, 17, 20 and 23 only.
//They trigger alerts ready to be executed on real markets through TradingConnector
//available for Forex, indices, crypto, stocks - anything your broker offers for trading via MetaTrader4/5
Expand (29 lines)
Overview
Bollinger Bands Strategy with TradingConnector Alerts triggers pending stop orders and outputs formatted alert messages compatible with TradingConnector for automated execution on MetaTrader platforms. Long orders are placed when price crosses above the lower band, while short orders trigger on crossovers below the upper band. Unfilled pending orders are canceled on non-triggering bars. Drawn directly on the price chart, the strategy lacks explicit stop loss and take profit exit rules.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
length
int
20
length
mult
float
2.0
mult
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 plots Bollinger Bands on the price chart with adjustable length, standard deviation, and offset. It defines buy and sell zones using candle size percentage and body size thresholds. Long positions enter when the lower zone is breached without con
The Mean Reversion Strategy Template calculates a baseline mean using SMA, EMA, or VWAP alongside upper and lower deviation bands based on standard deviation, ATR, or percentage offsets. It generates long and short entries when price touches, bounces from, or
This strategy generates buy and sell signals based on Bollinger Band crossovers combined with a simple moving average trend filter. It enters a long position when price crosses above the lower band while trading above the SMA filter line, and enters a short po
This strategy executes trades based on price interactions with standard Bollinger Bands plotted on the price chart. It calculates a simple moving average basis line along with upper and lower standard deviation bands. Long entries are triggered when price cros
This strategy scaffold calculates a standard Volume Weighted Average Price (VWAP) alongside upper and lower volatility bands set 1.5 ATRs away. It generates long entry signals when a confirmed bar closes below the lower band and short entry signals when a conf
Greeffer's Scalping Strategy combines multi-timeframe Exponential Moving Averages, Bollinger Bands, and Donchian Channels to execute dip-buying trades directly on the price chart. It triggers long entries when price dips below both the lower Donchian Channel a