“Short every pump in a bear market” they said. Gunbot now allows you to fully automate that.

Gunbot is one of the most used tools for trading automation at spot trading exchanges like Binance. From now on, you can also use Gunbot to automate trading at margin trading exchanges.

Bitmex is the first supported exchange for margin trading with Gunbot. Expect broader exchange support soon.

Due to the differences between spot trading and margin, there are quite a few changes to how Gunbot works on Bitmex. In this article you’ll learn about the main differences and how to work with Gunbot on a margin trading exchange.

Gunbot – Crypto Trading Bot. Start free trial | gunbot.com

What’s changed to allow for margin trading?

On a spot trading exchange like Binance, trading happens with buy and sell orders. Whatever happens after the order, you own the coins.

With margin trading, it’s a bit more complicated. There are a few more trade types, you don’t own the quote currency after “buying” it — you even risk losing your whole investment by a liquidation of your position.

To optimize Gunbot for margin trading, a few changes were required:

Make it possible to open long and short positionsUse leverageTriggers for closing positionsAllow for post only-orders

The basics: balance settings and leverage

In this example Gunbot will trade XBTUSD and will invest 300 contracts per trade, using 5x leverage.

Balance settings in Gunbot define how much to spend on a single trade. These settings are part of a trading strategy (which can be assigned to one or more trading pairs). Like any strategy setting, you can override it at pair level.

On Bitmex, the TRADING_LIMIT option defines the number of contracts to open a position with.

LEVERAGE defines the factor of leverage used, expressed as a number between 0 (cross leverage) and 100 (100x leverage).

Strategies: mean reversion or trend following?

While some traders will want to short every pump, others prefer to ride the trend. Gunbot offers trading strategies for both types of traders, some strategies are even available in both mean reversion and trend following variants.

This is how you create a new strategy.

A strategy in Gunbot is a set of rules that define how it trades. Every trading pair can be assigned a single strategy. Different pairs can use different trading strategies.

The main components of this are buy and sell methods, which define when the bot is allowed to place orders. Strategies can be assigned to one or more trading pairs.

The BUY_METHOD defines which trading method is used for opening long positions. In the example above it’s set to use an EMASPREAD method, which opens a long position when the distance between slow and fast EMA is getting smaller and fast EMA is below slow EMA.

The SELL_METHOD option sets the method for opening short positions. In this case the pp method is used (short for pingpong), which will open a short position as soon as the bid price drops below a configurable price.

You don’t have to trade both directions. If you only want to go short, you can just disable the buy side.This is by no means a comprehensive overview of Gunbot strategy capabilities. Read more about Gunbot strategies on the project wiki on Github.

Let’s say you really want to short every pump, here’s one way to do that:

Create a trading strategy with tssl as sell method, this strategy is able to trail prices up until they start dropping againEnable the MEAN_REVERSION mode for this strategySet a SHORT_LEVEL, which is a percentage above EMA where you allow Gunbot to go short. If you want to disregard every price movement that does not reach at least 1% above EMA, set this to 1.Set a BUY_RANGE to trail prices upwards of SHORT_LEVEL. A range of 0.5 would mean that price has to fall >0.5% before the trailing stop hits and a short position is opened. As long as prices keep increasing, the stop moves along 0.5% below the best bid price.

The settings for period and EMAs are fully configurable.

Taking profit. How to close positions at the best rate

Closing position with Gunbot is easy: they are closed when a set ROE is reached (short for Return on Equity), or ROE_TRAILING can be used to aim for maximum returns and only close a position after ROE starts to decrease.

Be aware that ROE in Gunbot does not take leverage into consideration, it’s defined as a simple percentage from the entry price. This means that if your position has an entry price of 100, you will reach 1% ROE when at 101.

With ROE trailing, you can greatly improve the returns on your positions.

The trailing logic is exactly the same as for the Gunbot tssl strategy, the only difference is that the trailing range is defined as a percentage from ROE. This way you can define the sensitivity for trailing, setting a really sensitive trailing range of 1 will cause Gunbot to keep the position as long as ROE keeps increasing and close it the first time ROE drops by 1%.

In case you don’t care about ROE for individual trades, look into the ichimoku strategy, which offers some custom triggers for closing positions.

Order types and rate manipulation

Gunbot places limit orders at ask when buying, and at bid when buying.

If that doesn’t work for you, you can select which types of orders need to be placed as market orders. For example you could only send stop orders as market, while all others are placed as limit orders.

If you don’t want to use market orders, but want to have a higher chance that your trade will get executed immediately, you can use the PRE_ORDER_GAP option. This feature let’s you set a percentage ahead of the best bid/ask price, and i.e. places an order at a 0.5% higher rate than the best bid on the books. This reduces the risk compared to a market order, while still massively increasing the chance of filling the order fast.

The same PRE_ORDER_GAP feature can be used to do the opposite when using a negative gap: place orders behind the best bid/ask that won’t execute immediately but sit on the book waiting to be executed. When you want to be 100% to collect maker fees for trades, you can enabled to MAKER_FEES option to place such orders as Post-Only.

Custom trading triggers through TradingView

You can combine Gunbot strategies (or forget about the native strategies at all) with trades triggered through email alerts sent by TradingView.

Read more about that in my article about using Gunbot to execute alerts.

Use Ichimoku with Renko charts

Gunbot v12 natively supports Renko charts. The Ichimoku strategy got tuned to be used with Renko.

In next releases, support for Renko and other types of charts will be rolled out to other strategies.

Testing Gunbot is free on Bitmex Testnet

Gunbot can be used at Bitmex Testnet without any restrictions. You do not need to register your API key, just download from Github, install and start evaluating.

Of course you can’t earn actual money there, but it’s a great way to learn the basics of Gunbot without any risk.

If you liked this story, please feel free to waste 15–20 seconds to give it 50 claps.

Trading Automation on Bitmex with Gunbot was originally published in Gunbot on Medium, where people are continuing the conversation by highlighting and responding to this story.

Gunbot – Medium 

Read More 

Previous

Leave a Reply

Your email address will not be published. Required fields are marked *