Gunbot wiki
Wiki em português
English
English
  • Welcome to the Gunbot wiki
  • About
    • What's new?
      • New in v22
      • New in v20
      • New in v18
      • New in v16.7+
      • New in v16
      • New in v15
      • New in v13 / v14
      • New in v12
      • New in v11
      • New in v10
      • New in v9
      • New in v8
      • New in v7
      • New in v6
    • Supported exchanges
      • Creating API keys
      • Websockets support
    • License info & system specs
      • How to create a wallet
    • Purchasing Gunbot
  • Setup & general settings
    • Installation & startup
      • Quickstart guide
      • Download software
      • Windows installation
      • macOS installation
      • Linux installation
      • ARM installation
      • How to enable SSL/TLS
      • Running multiple instances
      • Headless mode
    • Global settings
      • Import settings
      • Bot settings
      • Cancel orders
      • Advanced
    • Profile settings
      • Exchanges
      • Gunthy wallet
      • Edit license
      • GUI authentication
      • Telegram
      • Tournament
  • How to work with Gunbot
    • Learning the basics
      • Trading logic
      • Important settings
      • Order types
      • Period
      • Trailing
      • ROE trailing
    • Strategies & pairs
      • Easy edit
      • Strategy editor
      • Trading pairs
        • Pair processing
    • Chart & results
    • Extra modules
      • AutoConfig
      • Backtesting
      • Code editor
      • TradingView Alerts
        • IMAP listener
      • Alerts (beta)
  • Trading strategy options
    • About Gunbot strategies
      • Trading methods
      • Protections
    • Regular strategies (spot trading)
      • ADX
      • ATRTS
      • Bollinger Bands
      • Bollinger Bands (TA)
      • EMA spread
      • Emotionless
      • Gain
      • Ichimoku
      • MACD
      • MACDH
      • Pingpong
      • Stepgain
      • Spotgrid
      • Spotgrid Advanced
      • StepGrid
      • SMA cross
      • Support / Resistance
      • Tssl (trailing stop / stop limit)
      • Time series analysis
    • Margin trading strategies
      • ADX
      • ATRTS
      • Bollinger Bands
      • Bollinger Bands (TA)
      • EMA spread
      • Futures Grid
      • Gain
      • Ichimoku
      • MACD
      • MACDH
      • Pingpong
      • Stepgain
      • SMA cross
      • Tenkan
      • Tssl (trailing stop / stop limit)
      • Time series analysis
    • Custom strategies
    • Balance settings
    • Confirming indicators
    • Dollar Cost Avg (DCA)
    • Reversal trading (RT)
    • TrailMe
    • Misc settings
  • More
    • Config marketplace
  • Various
    • Backups
    • Logs
    • Handling bags
    • Acronyms
  • Troubleshooting
    • Critical errors
    • Bot does not trade
    • Reset password
Powered by GitBook
On this page
  • How to work with this strategy
  • Long
  • Short
  • Strategy parameters
  • Margin settings
  • Long Level
  • Short Level
  • ROE
  • PND
  • PND protection
  • Leverage
  • Stop Buy
  • Stop Sell
  • ROE Trailing
  • ROE Scalper
  • ROE Limit
  • Pre Order
  • Pre Order Gap
  • Mean Reversion
  • Buy settings
  • Buy enabled
  • NBA
  • Sell settings
  • Sell enabled
  • Indicator settings
  • Period
  • Low BB
  • High BB
  • SMA Period
  • Standard Deviation
  • Slow EMA
  • Medium EMA
  • Balance settings
  • Confirming indicators + advanced indicator settings
  • Misc settings
  • Dollar cost avg settings
  • DCA Method
  • Reversal trading settings
  • TrailMe settings

Was this helpful?

  1. Trading strategy options
  2. Margin trading strategies

Bollinger Bands

PreviousATRTSNextBollinger Bands (TA)

Last updated 4 years ago

Was this helpful?

This page describes how margin trading works with the Bollinger Bands strategy. The triggers for trades are slightly different than in the same strategy for regular trading.

How to work with this strategy

Expected behavior for margin trading

Gunbot will open one position, either long or short, and close this position when the target is reached. When the stop is hit before profitably closing a trade, Gunbot will place a stop order at loss. After closing a position, Gunbot will again look to open a new long or short position. Gunbot will not add to existing open positions.

Please don't manually add to or reduce positions opened by Gunbot, unless you stop running Gunbot on this trading pair until you've closed this position.

Using bb (margin) is only meaningful with MEAN_REVERSION enabled.

The info below assumes you have set this.

The examples below show how the basic triggers for bb work. Additionally, you can use confirming indicators and settings like ROE trailing.

Long

  • A long position is opened when the ask price is below LOW_BB and LONG_LEVEL. In the example above LOW_BB would be set to 0, which represents the actual lower Bollinger Band. With different values you could set a target above (positive value) or below (negative value) the lower band.

  • Position is closed when the desired ROE (return on equity) is reached. This is a percentage from the entry point, taking leverage into consideration.

  • A position is closed at loss when a stop is hit.

Short

  • A short position is opened when the bid price is above HIGH_BB and SHORT_LEVEL. In the example above HIGH_BB would be set to 0, which represents the actual upper Bollinger Band. With different values you could set a target below (positive value) or above (negative value) the upper band.

  • Position is closed when the desired ROE (return on equity) is reached. This is a percentage from the entry point, taking leverage into consideration.

  • A position is closed at loss when a stop is hit.

Strategy parameters

Following settings options are available for bb and can be set in the strategy configurator of the GUI or the strategies section of the config.js file.

Margin settings

Margin settings control settings like leverage and the target for ROE. These parameters are relevant when using bb as buy and/or sell method.

Long Level

This sets the target for opening a long position at a percentage above the highest EMA.

When you set this to 1, buy orders will only be placed when the current price is at least 1% above the currently highest EMA.

Values: numerical – represent a percentage.

Default value: 1

Affects

Does not affect

Strategy buy

RT buy

RT buyback

RT sell

Close

Stop limit

Strategy sell

DCA buy

Parameter name in config.js: LONG_LEVEL

Short Level

This sets the target for opening a short position at a percentage below the lowest EMA.

When you set this to 1, sell orders will only be placed when the current price is at least 1% below the currently lowest EMA.

Values: numerical – represent a percentage.

Default value: 1

Affects

Does not affect

Strategy sell

RT buy

RT buyback

RT sell

Close

Stop limit

Strategy buy

DCA buy

Parameter name in config.js: SHORT_LEVEL

ROE

This sets the target for closing a position.

ROE is the Return On Equity for a position, the percentage profit and loss on your invested margin. This value is calculated in a similar way to how Bitmex calculates it, it does include leverage and does not include fees.

Examples:

Long position, 1x leverage. When price moves 1% above the average entry price, 1% ROE is reached.

Long position, 100x leverage (or cross leverage). When price moves 1% above the average entry price, 100% ROE is reached.

Short position, 20x leverage When price moves 1% below the average entry price, 20% ROE is reached.

Values: numerical – represent a percentage.

Default value: 1

Affects

Does not affect

Close

RT buy

RT buyback

RT sell

Close

Stop limit

Strategy buy

Strategy sell

DCA buy

Parameter name in config.js: ROE

PND

Use "PND" logic to close trades. This mode tries to not close a position before a pump or dump has fully played out - usually beats ROE trailing performance.

Respects the minimum ROE set.

Values: true or false

Default value: false

Affects

Does not affect

Close

RT buy

RT buyback

RT sell

Close

Stop limit

Strategy buy

Strategy sell

DCA buy

Parameter name in config.js: PND

PND protection

Threshold to close a position when it drops below ROE again.

A value of 1.5 means that if ROE reached 1.5x the minimum target, the position will get closed immediately if the trend turns.

Values: numerical

Default value: 1.5

Affects

Does not affect

Close

RT buy

RT buyback

RT sell

Close

Stop limit

Strategy buy

Strategy sell

DCA buy

Parameter name in config.js: PND_PROTECTION

Leverage

Sets the leverage for opening any position. Setting 0 places the order with cross margin.

On Binance Futures you must set leverage per pair on the exchange itself.

Values: numerical

Default value: 0

Affects

Does not affect

Strategy buy

RT buy

Strategy sell

RT buyback

RT sell

Close

Stop limit

Close

DCA buy

Parameter name in config.js: LEVERAGE

Stop Buy

Places a market stop order for a long position, at the same time as the position is opened.

When set to 1 and a long order is opened at a price of 100, a stop market order will be placed at 99.

This setting is exclusive to Bitmex

Values: numerical - represents a percentage.

Default value: 0

Affects

Does not affect

Strategy buy

RT buy

RT buyback

RT sell

Close

Stop limit

Close

Strategy sell

DCA buy

Parameter name in config.js: STOP_BUY

Stop Sell

Places a market stop order for a short position, at the same time as the position is opened.

When set to 1 and a short order is opened at a price of 100, a stop market order will be placed at 101.

This setting is exclusive to Bitmex

Values: numerical - represents a percentage.

Default value: 0

Affects

Does not affect

Strategy sell

RT buy

RT buyback

RT sell

Close

Stop limit

Close

Strategy buy

DCA buy

Parameter name in config.js: STOP_SELL

ROE Trailing

Use this to enable tssl-style trailing for ROE.

Trailing limit is set with ROE_LIMIT.

Values: true or false

Default value: false

Affects

Does not affect

Close

RT buy

RT buyback

RT sell

Strategy sell

Stop limit

Close

Strategy buy

DCA buy

Parameter name in config.js: ROE_TRAILING

ROE Scalper

Use this to enable an alternate trailing mechanism for closing positions.

Trailing limit is set with ROE_LIMIT. Additionally ROE_TRAILING must be enabled.

Values: true or false

Default value: false

Affects

Does not affect

Close

RT buy

RT buyback

RT sell

Strategy sell

Stop limit

Close

Strategy buy

DCA buy

Parameter name in config.js: ROE_SCALPER

ROE Limit

This sets the range for ROE trailing.

ROE trailing:

Range is a percentage of current ROE. Setting a ROE_LIMIT of 5 at a ROE target of 1 would set an initial range between 0.95 and 1.05.

ROE scalper:

Range is an absolute ROE value. Setting a ROE_LIMIT of 5 at a ROE target of 10 means that the trailing stop is initially set at ROE 5 (ROE minus ROE_LIMIT).

Both:

As long as ROE keeps increasing, the range moves along with ROE. As soon as ROE start decreasing, the lower range gets frozen. A close order is placed when ROE crosses the lower limit.

Values: numerical – represent a trailing range.

Default value: 1

Affects

Does not affect

Close

RT buy

RT buyback

RT sell

Strategy sell

Stop limit

Close

Strategy buy

DCA buy

Parameter name in config.js: ROE_LIMIT

Pre Order

When set to true, limit orders will placed at a configurable rate beyond the best bid/ask price to get ahead of the order book.

Values: true or false

Default value: false

Affects

Does not affect

Close

RT buy

Strategy sell

RT buyback

Strategy buy

RT sell

Stop limit

DCA buy

Parameter name in config.js: PRE_ORDER

Pre Order Gap

Sets the gap between the best bid/ask price in the orderbook and the rate at which a limit order gets placed. Long orders are placed at ask + gap. Short orders are placed at bid - gap.

It is possible to use negative values, this will increase the chance of receiving maker fees.

Example when set to 1 and a buy signal occurs at an ask price of 100: a limit order gets placed at a rate of 101. When set to -1 and a buy signal occurs at an ask price of 100: a limit order gets placed at a rate of 99.

Don't use a negative gap together with STOP_BUY and/or STOP_SELL, as these stops do not combine well with position that do not always fill. Instead use STOP_LIMIT.

Values: numerical - represents a percentage.

Default value: 0

Affects

Does not affect

Strategy sell

RT buy

Strategy buy

RT buyback

RT sell

Stop limit

DCA buy

Close

Parameter name in config.js: PRE_ORDER_GAP

Mean Reversion

When set to true, the strategy follows a mean reversion way of trading, instead of trend following.

This setting must be enabled to use bb as buy or sell method. When set to false, this strategy reverts to the same behavior as the gain strategy.

Long and short levels are reversed in this mode, long level is placed below EMA, short level is placed above EMA.

Values: true or false

Default value: false

Affects

Does not affect

Strategy sell

RT buy

Strategy buy

RT buyback

RT sell

Stop limit

DCA buy

Close

Parameter name in config.js: MEAN_REVERSION

Buy settings

Buy settings are the primary trigger for opening long positions. These parameters control the execution of buy orders when using bb as buy method.

Buy enabled

Set this to false to prevent Gunbot from placing buy orders.

Values: true or false

Default value: true

Affects

Does not affect

Strategy buy

Strategy sell

DCA buy

Stop limit

RT buy

Close

RT buyback

RT sell

Parameter name in config.js: BUY_ENABLED

NBA

"Never Buy Above". Use this to only allow buy orders below the last sell rate.

This sets the minimum percentage difference between the last sell order and the next buy. The default setting of 0 disables this option.

When set to 1, Gunbot will only place a buy order when the strategy buy criteria meet and price is at least 1% below the last sell price.

Values: numerical, represents a percentage.

Default value: 0

Affects

Does not affect

Strategy buy

Strategy sell

Stop limit

Close

RT sell

DCA buy

RT buy

RT buyback

Parameter name in config.js: NBA

Sell settings

Sell settings are the primary trigger for opening short positions. These parameters control the execution of sell orders when using bb as sell method.

Sell enabled

Set this to false to prevent Gunbot from placing sell orders.

Values: true or false

Default value: true

Affects

Does not affect

Strategy sell

Strategy buy

Stop limit

RT buy

RT sell

RT buyback

Close

DCA buy

Parameter name in config.js: SELL_ENABLED

Indicator settings

Relevant indicators for trading with bb.

These settings have a direct effect on trading with bb, this is where you configure how Bollinger Bands are calculated and at which distance from them orders should be placed. Additionally, long and short level are dependent on EMA.

Period

This sets the candlestick period used for trading, this affects all indicators within the strategy.

Setting a short period allows you to trade on shorter trends, but be aware that these will be noisier than longer periods.

Values: numerical– represents candlestick size in minutes.

Default value: 15

Affects

Does not affect

Strategy sell

RT buy

Strategy buy

RT buyback

RT sell

Close

Stop limit

DCA buy

Parameter name in config.js: PERIOD

Low BB

This sets the target for buying. Negative values are allowed.

The bot will buy when price hits the set percentage from the lower Bollinger Band and the price is below the entry point as defined by BUY_LEVEL.

When set to 0, the lower Bollinger Band is the target. When set to 30, the target is 30% above the lower Bollinger Band - the upper band is at 100% from the lower band. Negative values are allowed.

Values: numerical – represent a percentage.

Default value: 0

Affects

Does not affect

Strategy buy

RT buy

RT buyback

RT sell

Close

Stop limit

Strategy sell

DCA buy

Parameter name in config.js: LOW_BB

High BB

This sets the target for selling. Negative values are allowed.

The bot will sell when price hits the set percentage from the upper Bollinger Band and GAIN is reached.

When set to 0, the upper Bollinger Band is the target (well, almost). When set to 30, the target is 30% under the upper Bollinger Band - the lower band is at 100% from the upper band. Negative values are allowed.

Values: numerical – represent a percentage.

Default value: 0

Affects

Does not affect

Strategy sell

RT buy

DCA buy (when using HIGHBB option for DCA)

RT buyback

RT sell

Close

Stop limit

Strategy buy

Parameter name in config.js: HIGH_BB

SMA Period

This defines the number of periods used for calculating Bollinger Bands.

Values: numerical – represents a number of candlesticks.

Default value: 50

Affects

Does not affect

Strategy sell

RT buy

Strategy buy

RT buyback

DCA buy (when using HIGHBB option for DCA)

RT sell

Close

Stop limit

Parameter name in config.js: SMAPERIOD

Standard Deviation

This value defines the multiplier used for calculating Bollinger Bands.

Values: numerical (recommended: between 1.9 and 2.1) - represents a multiplier value used in the bollinger bands calculation.

Default value: 2

Affects

Does not affect

Strategy sell

RT buy

Strategy buy

RT buyback

DCA buy (when using HIGHBB option for DCA)

RT sell

Close

Stop limit

Parameter name in config.js: STDV

Slow EMA

Set this to the amount of candlesticks you want to use for your slow EMA. The closing price for each candle is used in the slow EMA calculation.

For example: when you set PERIOD to 5, and want to use 2h for slow EMA – you need to set EMA1 to 24 (24 * 5 mins).

Values: numerical – represents a number of candlesticks.

Default value: 16

Affects

Does not affect

Strategy buy

RT buy

RT buyback

RT sell

Close

Stop limit

Strategy sell

DCA buy

Parameter name in config.js: EMA1

Medium EMA

Set this to the amount of candlesticks you want to use for your medium EMA. The closing price for each candle is used in the fast EMA calculation.

For example: when you set PERIOD to 5, and want to use 1h for medium EMA – you need to set EMA2 to 12 (12 * 5 mins).

Values: numerical – represents a number of candlesticks.

Default value: 8

Affects

Does not affect

Strategy buy

RT buy

RT buyback

RT sell

Close

Stop limit

Strategy sell

DCA buy

Parameter name in config.js: EMA2

Balance settings

Confirming indicators + advanced indicator settings

Misc settings

Dollar cost avg settings

DCA Method

Values: NATIVE / TENKAN

Default value: TENKAN Setting NATIVE effectively disables DCA in this strategy

Affects

Does not affect

DCA

Strategy buy

Strategy sell

Close

RT sell

Stop limit

RT buyback

RT buy

Parameter name in config.js: DCA_METHOD

Reversal trading settings

RT is not intented to be used for margin trading.

TrailMe settings

TrailMe is not intented to be used for margin trading.

Placeholders

The following parameters in config.js have no function for this strategy and act as placeholder.

Parameter

Description

ATRX

Placeholder.

ATR_PERIOD

Placeholder.

BUYLVL1

Placeholder.

BUYLVL2

Placeholder.

BUYLVL3

Placeholder.

BUYLVL

Placeholder.

BUY_LEVEL

Placeholder.

BUY_RANGE

Placeholder.

DISPLACEMENT

Placeholder.

DOUBLE_CHECK_GAIN

Placeholder.

FAST_SMA

Placeholder.

GAIN

Placeholder.

ICHIMOKU_PROTECTION

Placeholder.

KIJUN_BUY

Placeholder.

KIJUN_CLOSE

Placeholder.

KIJUN_PERIOD

Placeholder.

KIJUN_SELL

Placeholder.

KIJUN_STOP

Placeholder.

KUMO_BUY

Placeholder.

KUMO_CLOSE

Placeholder.

KUMO_SELL

Placeholder.

KUMO_SENTIMENTS

Placeholder.

KUMO_STOP

Placeholder.

MACD_LONG

Placeholder.

MACD_SHORT

Placeholder.

MACD_SIGNAL

Placeholder.

PP_BUY

Placeholder.

PP_SELL

Placeholder.

RENKO_ATR

Placeholder.

RENKO_BRICK_SIZE

Placeholder.

RENKO_PERIOD

Placeholder.

SELLLVL1

Placeholder.

SELLLVL2

Placeholder.

SELLLVL3

Placeholder.

SELLLVL

Placeholder.

SELL_RANGE

Placeholder.

SENKOUSPAN_PERIOD

Placeholder.

SLOW_SMA

Placeholder.

TAKE_BUY

Placeholder.

TBUY_RANGE

Placeholder.

TENKAN_BUY

Placeholder.

TENKAN_CLOSE

Placeholder.

TENKAN_PERIOD

Placeholder.

TENKAN_SELL

Placeholder.

TENKAN_STOP

Placeholder.

TP_PROFIT_ONLY

Placeholder.

TP_RANGE

Placeholder.

TSSL_TARGET_ONLY

Placeholder.

USE_RENKO

Placeholder.

These settings are global and apply to all pairs running this strategy. When you want a specific parameter to be different for one or more pairs, use an at the pair level.

Using the BUY_METHOD and SELL_METHOD parameters you can combine different methods for buying and selling. This strategy page assumes both BUY_METHOD and SELL_METHOD are set to bb. Accepted values are all strategy names as listed .

Only use .

When set to TENKAN Gunbot will place DCA orders in exactly the same way as in the strategy. Each DCA order is in size of TRADING_LIMIT.

override
here
Balance settings
Confirming indicators
Misc settings
Tenkan
TrailMe
supported values