This page describes how margin trading on Bitmex works with the MACD strategy. The triggers for trades are slightly different than in the same strategy for regular trading.
The expected behavior for margin trading with Gunbot is that it 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.
A long position is opened when MACD crosses up the signal line.
A short position is opened when MACD crosses down the signal line.
A position is closed when the desired ROE
is reached.
A position is closed at loss when STOP_LIMIT
is reached.
Following settings options are available for MACD
and can be set in the strategy configurator of the GUI or the strategies section of the config.js file.
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 override 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 MACD
. Accepted values are all strategy names as listed here.
Margin settings control settings like leverage and the target for ROE. These parameters are relevant when using MACD
as buy and/or sell method.
This sets the target for closing a position.
ROE is measured as a percentage from the opening rate of a position, leverage and fees are not taken into consideration.
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
Sets the leverage for opening any position. Setting 0 places the order with cross margin.
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
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.
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
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.
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
Use this to enable tssl-style trailing for ROE.
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
This sets the range for ROE trailing.
Setting a range of 5% at a ROE target of 1 would set an initial range between 0.95 and 1.05.
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 percentage of ROE.
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
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
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.
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
Buy settings are the primary trigger for opening long positions. These parameters control the execution of buy orders when using MACD
as buy method.
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
"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 are the primary trigger for opening short positions. These parameters control the execution of sell orders when using MACD
as sell method.
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
Relevant indicators for trading with EMA spread.
These settings have a direct effect on trading with MACD
.
This sets the candlestick period used for trading, this affects all indicators within the strategy.
Only use supported values.
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
The number of periods used for calculating the short-term moving average for MACD.
Values: numerical, represents a number of periods.
Default value: 5
Affects | Does not affect |
Strategy sell | RT buy |
Strategy buy | RT buyback |
​ | RT sell |
​ | Close |
​ | Stop limit |
​ | DCA buy |
Parameter name in config.js
: MACD_SHORT
The number of periods used for calculating the long-term moving average for MACD.
Values: numerical, represents a number of periods.
Default value: 20
Affects | Does not affect |
Strategy sell | RT buy |
Strategy buy | RT buyback |
​ | RT sell |
​ | Close |
​ | Stop limit |
​ | DCA buy |
Parameter name in config.js
: MACD_LONG
The number of periods used for calculating the MACD signal line.
Values: numerical, represents a number of periods.
Default value: 10
Affects | Does not affect |
Strategy sell | RT buy |
Strategy buy | RT buyback |
​ | RT sell |
​ | Close |
​ | Stop limit |
​ | DCA buy |
Parameter name in config.js
: MACD_SIGNAL
DCA is not intented to be used for margin trading.
RT is not intented to be used for margin trading.
TrailMe is not intended to be used with this strategy.
The following parameters in config.js
have no function for this strategy and act as placeholder.
Parameter | Description |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |
| Placeholder. |