All indicators

BollingerBands Strat + pending order alerts via TradingConnector

Oct 28, 2021

Static chart image
SignalsChannelsMoving Averages

The BollingerBands Strat + pending order alerts via TradingConnector tool provides an automated trading framework that combines the classic Bollinger Bands mean-reversion logic with specialized alert functionality for external execution. It aims to bridge the gap between TradingView strategy signals and broker execution by generating specific syntax for pending orders and cancellations.

Usage

The strategy is designed to identify potential entry points when the price interacts with the outer Bollinger Bands.

  • Long Entry: Triggered when the price crosses over the lower band. A pending long stop order is placed at the lower band level.
  • Short Entry: Triggered when the price crosses under the upper band. A pending short stop order is placed at the upper band level.
  • Order Management: The script automatically generates "cancel" alerts if the market conditions change and the entry criteria are no longer met. This ensures that unfilled pending orders do not remain active indefinitely.

To use this script for automated execution, users must configure an alert on the strategy and select "alert() function calls only" in the Create Alert popup. The messages are formatted to be compatible with the TradingConnector bridge for MetaTrader 4/5.

Details

This implementation is based on the built-in Bollinger Bands strategy but is enhanced with specific alert() calls. Unlike standard strategy alerts that only notify on fill, this script triggers alerts when the strategy.entry (pending order) is first placed and when strategy.cancel is called.

The logic utilizes a Simple Moving Average (SMA) as the basis and calculates the upper and lower bands based on a user-defined number of standard deviations. The use of strategy.oca.cancel ensures that only one side of the Bollinger Band trade is active at a time within the One-Cancels-All group.

Settings

  • Length: Determines the lookback period for the Simple Moving Average and the Standard Deviation calculation.
  • Multiplier: Sets the number of standard deviations away from the basis for the upper and lower bands. Increasing this value makes the bands wider, leading to fewer but potentially more significant signals.

FAQ

How do I automate the trades from this strategy?

You must set up a TradingView alert using the "alert() function calls only" setting. These alerts contain the price data and direction required for external bridge software like TradingConnector to execute the trades in MetaTrader.

What happens if a pending order is not filled?

The script includes logic to monitor the entry conditions. If the crossover/crossunder condition is no longer valid, a "cancel" alert is triggered to remove the pending order from your broker's terminal.

How can I access BollingerBands Strat + pending order alerts via TradingConnector?

You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.