Watch our Mean Reversion Bot in Action
Getting the Right Files
First you need to download the required files. Let’s go to GitHub for that here and download the zip file. Here
Once you get the files, you will have the following folder without the “permission error” file. That will only be created if you encounter an error. All you have to do is, to start editing the “settings page” and start the HFT Mean Reversion file.
Important Note: When you are adjusting your settings, all the numbers that contains the word “percentage” are to be put like you say it. If you want 1%, please type 1, if you want 0.1% please only type 0.1.
Set Up
Hosting: This isn’t a piece of the settings page. However, we would like to mention that you will need a place to host the bot. It can be your personal desktop or laptop. Though, if you want the bot to run 24/7, we suggest using a VPN Service. Please read our Hosting guide if you do not know what it is. Alternatively, we offer hosting and set up, please contact us if you want us to help you get set up.
License key: Please put the license key provided by HFT Research upon your purchase. The bot will not work without a valid license key.
Platform: Currently our bots work on Binance Futures, ByBit USDT Settled contracts and ByBit Inverse contracts. We are working on adding FTX as well! You can choose one of the options above.
Public key: Place your public API key here
Secret Key: Place your Secret API key here
Symbol: Once you select your platform you can choose any of the available pairs that’s listed on the exchange. Please make sure to pay attention to BTCUSDT and BTCUSD as they are different pairs on ByBit. BTCUSDT is used for USDT settled contracts and BTCUSD is for inverse contracts. Interval: This is how often you want the bot to check your position’s PNL. You can choose this as low as 3 seconds but anything lower than might cause API issues as the exchange you are trading on might mark it as “spam”.
Opening Position
Trading Side: this setting is only applicable if you are using auto Open Position. If you are not using auto open position and entering manually or alerts, the bot will be able to manage either a short or a long position.
Auto Open Position: You can only turn this setting on or off. If you have it on, the bot will only Buy or Sell depending on your settings under Trading Side. The safest way to use the bot is entering manual or with an alert as simple as RSI oversold condition to go long will give you better entry.
Cooldown in Seconds: If you are using auto open position off, you can ignore this setting. Otherwise, please select how long you want the bot to wait after closing a position before opening a new position.
5min in seconds = 300
15min in seconds = 900
1 hour in seconds = 3600
If your entry side is buy, the bot will ignore all the short signals generated and vice versa. It will trade one side of the market!
Use SMA: You can choose to use SMA as an indicator to use for your entry. If the price is above the SMA, the bot will look to long. On the contrary, if the price is below SMA, the bot will look to short. You can turn this on and off.
smaLength: Here you can select the length or period of your SMA length. Some popular ones are 21, 50, 100 and 200.
smaTimeFrame: You can select the timeframe for SMA here. Some popular ones are min60, min240, day
useBB: Here, you can choose if you want to use Bollinger Bands as an indicator for your entry. If the price is below the lower band of Bollinger Bands, the bot will trigger a long given that the price is also above the SMA length if you are using that as well.
bbLength: Select the length of your Bollinger Bands. The most common is 20.
bbTimeFrame: Choose the timeframe for Bollinger Bands. It can be different than SMA length if you are using.
Thoughts
There are a few different strategies you can make of using these different strategies.
- Some traders prefer to select SMA on a higher time frame like 4 hours or daily which lets them see the bigger picture. On the other hand, they select a lower time frame for Bollinger Bands in order to get in at the small dips while the overall market is bullish. The same strategy can be applied for the short side if the trader is feeling that the market is bearish.
- Some more conservative traders prefer to use both indicators on higher time frames such as daily SMA and hourly BB. Therefore, they deploy more capital into each trade and order which compensates the lack of activity due to trading higher time frames.
Managing Position
This is the most important part of the settings page and where the magic happens. So please read it a few times and make sure to have good grip on the concept to make the most out of the bot.
First Order Size: This is the number of contracts you want to place as your first order. Your first order size is important because the bot will use this number to make all the following calculations. Also, it is the basis of your risk management in this context.
Order Size Multiplier: This is the number that the bot will multiply each order by. If you want your orders to go linear, you can set it up as 1 and the bot will keep placing the same order size as in your first order size settings. However, if you want to aggressive or use the bot with manual entry and scalp the market. You can choose a bigger multiplier than 1. It will bring your average down faster but your position size might get out of hand really quickly. We will dive deeper into it in the example section down below.
Order Spread Percentage: This is how far you want the bot to place your orders away from each other. If Bitcoin is at 10,000$ and you select 0.1, then the bot will place your orders 10$ away from each other. If you chose 1, the bot will place your orders 1% (100$) away from each other. This comes in handy when you want to properly analyze your risk and downside.
Coverage Percentage: Here, you choose how much of a downside you want to cover if you are long and how much upside you want to cover if you are short. Let’s say Bitcoin again is at 10,000$ and for a fact that you know Bitcoin will not go below 3000$. Effectively, you can choose to cover 70% downside and really lower your risk. You would be good as long as Bitcoin doesn’t go below 3000$.
orderSpreadMultiplier: This piece of setting works exactly like order size multiplier. However, instead of multiplying your order size, it will multiply your order spread. This is useful in the cases where you want to use a high order multiplier but you don’t want your trades to be so close to each other. This setting gives the trader the ability to manage risk and bankroll much more effectively.
Now we have the most important part done, let’s look at some different ways and scenarios you can use this bot.
Examples
Long Term Player
In this scenario, you are a conservative trader and you want to keep your exposure as low as possible. So, you go the guarantee way and say that Bitcoin can go to 1$ and I want to be prepared for it. But also, I don’t want my bot to be inactive, I want to see some trading action. Bitcoin is at 10,000 and you have exactly 10,000 USDT in your wallet. How can I set my bot up to satisfy my expectations?
First Order Size: We will select this at the end when we do the calculation to see what we can afford to have for this piece of setting.
Order Size Multiplier: We select 1. Because we don’t want our orders to multiply and end up having too much exposure. Going linear is always the safest.
Order Spread Percentage: We choose 0.1. So, the bot will place your orders 0.1% (10$) away from each other. That way, your bot will be active and you will see some trading action.
Coverage Percentage: We go with 100. Because, you want be prepared for Bitcoin going to 1$, you are planning and allocating your money for the worst-case scenario.
Now we have selected the parameters, let’s see what we can afford for our first order size.
We are going to place orders that are 0.1% away from each other to cover a 100% price drop. So, if Bitcoin goes to 1$, we will end up placing 100 / 0.1 = 1000 orders. We can even calculate the prices that we will place our orders if Bitcoin is 10,000$
1st order = 10,000
2nd order = 9,990
3rd order = 9,980
…
998th order = 20
999th order = 10
1000th order = 0
Alternatively, if we have 10,000$ in our account and we plan to place 1,000 orders, our first order size should be 10,000 / 1,000 = 10$
Now even if the price goes down to 1$, we are still safe and just waiting for a rebound to get out of the position. This is pretty much dummy proof version of the strategy and you can literally set it like that and forget it.
Even if you entered and deployed the strategy right at when BTC was at 20,000, you would get out of the position.
Though, obviously with an extreme safety measures like this, your ROI will be lower.
The Moderate Risk Taker
In this case, you aren’t so much of a safe player but also you are aware of the risks of trading. You just like me think and believe that Bitcoin wouldn’t go below 3,000$ at this point for the foreseeable future. However, you don’t want to stay too far away from the price when it makes big moves. Plus, you have some time to look at the price and make the adjustments if price starts getting close to 3,000$. However, right now its at 10,000, so you are comfortable with this safety measure.
First Order Size: 0.001
Order Size Multiplier: 1.01. Now you are increasing your first order size by 1% each order. This will help you get your average closer to the current price exponentially. Be careful with this as it might get out of hand really quickly. Please make a copy of the following google sheet and play with the calculations to see if you can afford the size you are trading. Here
Order Spread Percentage: 0.1
Coverage Percentage: 70, since you want to cover 70% drop down to 3,000$
Now, we know we are going to put 700 orders and each order will increase by 1% in order to bring down the average a little faster. Though it comes at a cost of increasing position size, it will make your entry price closer to the current price. Here is the good and the bad part
When you place 700 orders while increasing each order by 1% starting with 0.001 contract size, you end up with 106 BTC position IF BTC drops to 3,000. However, your Average Price would be 3993$ while Bitcoin is at 3,000$ after a 70% correction. You are pretty close to the entry price but your position size is big.
If you trade on inverse contracts, it’s a bit cheaper because your minimum size is 1 contract. With the same settings above, your average price would be 3993$ as well but your position size would be 106k contracts which is a lot affordable than 106 BTC position.
Now let’s look at the day trader.
Day Trader, Higher risk more hands on approach
This is not advised if you are a novice trader or if you are still not 1000000% sure about how the bot works and what the variables are. However, if you have got that down, let’s look at how you can effectively scalp the market with this bot.
Again, with the same scenario above with the same balance, let’s look at some more high-risk hands-on strategies.
You as a trader believe that today believe that BTC wouldn’t go down more than 5% because of a strong support, already massively sold off on the higher time frames or whatever the reason might be. You got a lot of free time and can watch the market. Price is 10,000$ again and you have 10,000 USDT.
First Order Size: 0.001
Order Size Multiplier: 1.2 (very aggressive, only use it if you are sure about the volatility of the market)
Order Spread Percentage: 0.1
Coverage Percentage: 5 (since we believe if BTC were to drop, it would only drop 5% for the day)
5 / 0.1 = 50 orders that we need to place in total. You use 50x leverage on 10,000 USDT so your max position would be 50 BTC
If Bitcoin goes to 9500 and dips a little more, you risk of getting liquidated. So, you can see how aggressive the strategy is. However, if you were right and price didn’t dip below 9500 while showing some volatility, it would yield insanely high profits. Let’s explore the liquidation and profit aspect of this risky strategy.
If Bitcoin comes down to 9500, your position size is 55 BTC and your average price is 9549. So, you are only 49$ away from the current price after a 500$ dump. However, the liquidation price is at 9437 which is only 63$ away. Even though you are closer to your entry price than your liquidation price, this is a position that no trader wants to find him/herself in.
If you use 0.5% take profit which is pretty moderate, your 55 BTC position would yield you about 2,100$ which is a whopping 21% gain on the account balance.
All the scenarios are calculated with the assumption in mind that BTC drops from 10,000 straight down to 9500$. This is very unlikely because it either dumps slowly with relief rallies which you can get out of the position fairly easy or it goes down in a big red candle. All the big red candles usually have a big shadow/wick to it. So, you can probably get out on that little bounce as well.
Now let’s look at the Take Profit and Stop Loss management
Close Position
Type of TP: Select your desired take profit type: Current options are limit and trailing take profit. We are also working on ladder TP as well!
Limit TP Percentage: This setting is only relevant if you have chosen this as your type of TP otherwise you can ignore it. If you choose this, the bot will maintain a take profit order by this percentage away from the price.
If “trailing” doesn’t mean anything to you or what you read below doesn’t make sense please watch the video below to see what exactly it is.
Trailing Start: This is only valid if you chose trailing TP as your TP option. This is the percentage when the bot will start trailing. So, if you want the bot start trailing at 1%, this is where you put 1.
Trailing Percentage: This is only valid if you chose trailing TP. This is how far behind you want to trail the price. This number must be smaller than the number above. If you start trailing at 1% with say 0.2%, the bot will place a stop loss order at 0.8% and will keep moving it up staying 0.2% behind of the local high.
Use Stop Loss: Turn this on or off depending on if you want to use stop loss.
If you exercise good risk management, mean reversion can be absolutely safe to run without a stop loss.
Stop Loss percentage: The % value where you want to have your stop loss.
Closing Thoughts
There are many different ways to use this bot. You can fully automate it with extremely safe settings and be ready for any kind of price action. Or, you can choose to make your entries with TradingView scripts and let the bot dollar cost average into. On the ultimate end of the stick, you can be pretty aggressive and scalp the market when there is low or high volatility if you have time to baby sit the trades. It is really up to the imagination of the user at this point! That being said, we are always more than happy to help you strategize through it on discord or telegram!
Finally, we advise and personally use this bot on Binance FTX and ByBit
Please check out our other bots here and read our blog for more educational content for trading here
Visit our website: https://hftresearch.com/
Follow us on Twitter: https://twitter.com/HFTResearch
Telegram: https://t.me/HFTResearchChat
Discord: https://discord.gg/K7w2WnQ
Medium: https://medium.com/@HFTresearch
Contact: info@hftresearch.com