# BollingerBandStrategy¶

Bollinger Band Strategy is a strategy build to gain profit on alternately buying and selling shares. Bollinger Band Strategy calculates three lines of values:

• Middle band - simple moving average (SMA)
• Upper Band - middle band plus standard deviation of price multiplied by a variance impact parameter
• Lower Band - middle band minus standard deviation of price multiplied by a variance impact parameter

In the moment when the middle band crosses the upper or lower band from the proper side it is a signal for a strategy to make an order.

## Strategy settings¶

 NUMBER OF PERIODS Number of trades included in moving averages computation VARAINCE IMPACT Decides about importance of a variance value

## Case scenario¶

For case scenario Bollinger Band Strategy is set to default values and is executed on daily tick data.

Bollinger Band Strategy executes alternately buy and sell orders. If middle band crosses an upper band from the bottom side it is a signal for Bollinger Band Strategy to make a sell order. If middle band crosses a lower band from the top side it is a signal for Bollinger Band Strategy to make a buy order.

As can be seen in strategy statistics, Bollinger Band Strategy brought net profit of \$9.250.

## Development¶

Bollinger Band Strategy is composed of one trading action.

```action(tradingAction
.createOrderWith(
orderBuilder
.withSymbol(marketSymbol)
.side(SIDE)
.withPriceLimit(PRICE)
.withQuantity((s) -> BigDecimal.ONE))
.onNewOrderSent(ON_NEW_ORDER_SENT))
```

Action when fired checks conditions if it should buy or sell shares in the moment. If one of conditions is fulfilled then trading action makes order with proper side and price.

```private Consumer<TradeEvent> ON_TRADE = new Consumer<TradeEvent>() {
@Override