// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=5
strategy("Bolinger Bands Strategy",
overlay=true,
initial_capital=10000,
currency=currency.USD,
default_qty_type = strategy.percent_of_equity,
default_qty_value=100,
commission_type=strategy.commission.cash_per_contract,
commission_value=0.005, //Interactive Brokers rate
process_orders_on_close = true)
import AlphaCentauri66367/PineTradingbotWebhook/7 as tv
i_startTime = input.time(title="Start Filter", defval=timestamp("05 Nov 2021 09:30 +0000"), group="Time Filter", tooltip="Start date & time to begin searching for setups")
i_endTime = input.time(title="End Filter", defval=timestamp("1 Jan 2099 19:30 +0000"), group="Time Filter", tooltip="End date & time to stop searching for setups")
f_dateFilter = time >= i_startTime and time <= i_endTime
source = close
length = input.int(20, minval=1)
mult = input.float(2.0, minval=0.001, maxval=50)
[basis, upper, lower] = ta.bb(source, length, mult)
buyCondition = strategy.position_size == 0 and f_dateFilter and ta.crossover(close, lower)
sellCondition = strategy.position_size > 0 and f_dateFilter and ta.crossunder(close, upper)
plot(upper, 'BB upper', color = color.aqua)
plot(lower, 'BB lower', color = color.aqua)
webhookKey = "WebhookReceived:8c43d5"
orderRef='BB#1'
clientId=1
qty=100
if buyCondition
msg = tv.makeWebhookJson(webhookKey, orderRef, 'strategy.entrylong', qty, clientId=clientId)
alert(msg)
strategy.entry("BBandLE", strategy.long, stop=lower, alert_message = "Current buy " + str.tostring(close))
bgcolor(buyCondition ? color.new(color.blue, 30) : na)
if sellCondition
msg = tv.makeWebhookJson(webhookKey, orderRef, 'strategy.close', qty, clientId=clientId)
alert(msg)
strategy.close("BBandLE", alert_message = "Current close " + str.tostring(close))
// Moving Average Indicator {
fastAverage = ta.ema(close, 10)
slowAverage = ta.ema(close, 50)
plot(fastAverage, title = "EMA 10", color=color.red)
plot(slowAverage, title = "EMA 50", color=color.red)
// Show the moving average trend with a coloured background
backgroundColor = if close > fastAverage and fastAverage > slowAverage
color.new(color.green, 85)
else if close < fastAverage and fastAverage < slowAverage
color.new(color.red, 85)
else
color.new(color.orange, 90)
bgcolor(backgroundColor, title="EMA Background")
// }
Overview
Bolinger Bands Strategy opens a long position when the price crosses back above the lower band within a specified date filter and closes the position when the price crosses below the upper band. Fast and slow exponential moving averages are also calculated to color the chart background according to trend alignment. Users can adjust the band parameters and time filter range.
Bollinger Band crossover entry and exit signals
Webhook JSON alert creation for external trading bots
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Start Filter
time
timestamp("05 Nov 2021 09:30 +0000")
i_startTime
End Filter
time
timestamp("1 Jan 2099 19:30 +0000")
i_endTime
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 calculates Bollinger Bands and Aroon oscillator values to identify mean-reversion opportunities. It enters a long position using full equity when the closing price crosses below the lower Bollinger Band while Aroon Up remains above a user-specifi
Sick Sigma detects extreme statistical standard deviation moves (sigma events) to execute trades directly on the main price chart. The strategy supports both momentum and mean-reversion trading styles. Traders can configure calculation lookback periods, sigma
This strategy combines Volume Weighted Moving Average (VWMA) Bollinger Bands with 200-period and 50-period Exponential Moving Averages (EMAs). It identifies long trade opportunities when the 50 EMA is above the 200 EMA and price falls to or below the lower Fib
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 plots a Keltner channel from an EMA basis and ATR bands on the price chart. It enters long when price crosses back above the lower band while trading above a slower trend EMA, and short when price crosses back below the upper band while below tha
This strategy identifies shorting opportunities by calculating Fear and Greed zones based on price extremums relative to moving averages and standard deviation bands. It measures price deviation from recent highs or lows to detect extreme market conditions and