Disclaimer: The opinions expressed here are for general informational purposes only and are not intended to provide specific advice or recommendations for any specific security or investment product. You should never invest money that you cannot afford to lose. Before trading using complex financial products, please ensure to understand the risks involved. Past performance is no guarantee of future results.
Have you ever seen a chart and wished you could trade all its ups and downs? The profit potential may be tempting but watching candles form in real time can feel like tug of war. The market’s emotions channel through you and may change your mind. It’s normal to act on new or changing information, but we often end up wishing we stuck with our original plan. This is the mental war that all traders experience.
During pronounced bull and bear trends it’s easy to decide on a position. The tricky part, and where many trading bots struggle, is sideways markets. This is when price trades within a horizontal range, refusing to set a trend. In circumstances like these, a trader may employ the use of a gridbot. It’s a type of rule-based trading that buys and sells based on a predetermined range.
How does a Grid Bot work?
By first defining a range with a high and low, we can then fill in additional intervals for buy and sell orders. Ideally a trader should buy low and sell high, but this is challenging in practice. Few people are right about the near future. So like us, a Grid Bot doesn’t know it’s buying at the bottom, only that one of its intervals has been triggered. If price continues to slide past lower intervals, towards the bottom of the range, the Grid Bot will buy more. We may lose out by not calling the exact bottom, but averaging down our entry price is also a form of risk management. Diversifying our entry points means the outcome, good or bad, matters less. Assuming you’ve correctly identified a sideways market, a Grid Bot can profit. Managing risk helps ensure we can trade another day, which is more important than focusing on large profits.
In the example below, the horizontal lines make up our range. The green lines are our long intervals (buy) and the red ones are our short intervals (sell). Each time price crosses one of these intervals we would buy or sell accordingly.
In a worst-case scenario, let’s assume the price falls out of our range and the gridbot is forced to sell at a loss. Since the bot continued to buy in at lower prices, our losses will be less than if we bought with 100% of our money at a higher interval. This scenario also implies the price went straight down. In reality, a gridbot may buy and sell multiple times before an event like this happens.
There may be times you believe an asset is bound to go up, or down, and want to avoid opening positions in the opposite direction. For that, we have a Long-Only and Short-Only Grid Bot which we go into later.
Grid Bots are widely appreciated for their ability to find profits in volatile markets. It’s not a magic box, nor does understanding it require intense learning. To most traders, an easier understanding creates more trust. Some look down on this method of trading for its simplicity but if it’s successful then that’s money you didn’t have to work for, and nobody has ever complained about that.
When to start a Grid Bot?
This part relies entirely on your own analysis. The first question you’ll want to ask is where are the supports and resistances? The easiest way is to look for spots on the chart where price bounces in the opposite direction. We can use these to define a rough range for our Grid Bot.
A fresh setup may only have one major support and one major resistance, but this makes it hard to tell if the trend will last. On the flip side, a setup with well-defined support and resistance suggests the trend is coming to an end. You’ll have to make a judgment call on this.
Before confirming a Grid Bot setup you’ll also want to consider a couple things.
- What is the sentiment around this trading pair? If you’re feeling confident, you may be more comfortable with buying at lower prices. However, if the market is clearly trending in a direction, or if news has swayed public perception, a Grid Bot may not be so useful.
- On what timeframe have you found supports and resistances? This governs how long you’ll want to run the strategy. Sideways markets don’t last forever.
Using the Tuned Grid Bot
Now, understanding what I’ve just explained above, I’d like to present the 3 gridbots we developed. That’s the Grid Bot – Long and Short, Grid Bot – Long Only, and Grid Bot – Short Only. To access them, you can search them up by name in the public library. You’ll see we’ve also added comments that explain how they work.
The Long and Short Grid Bot
The default configuration is made up of two sets of 10 horizontal lines. The spacing of these lines is determined by the Grid Interval Percent. A Grid Interval Percent of 10.0% will generate all 20 lines between your defined range. Anything higher and the grid lines will form outside your top and bottom resistance.
The bottom 10 lines in green are our ‘buy’ lines. Each time a candle closes below one of these intervals, we create a long order worth 10% of our balance. The grid bot is designed to buy once at each level meaning the bot will only use 100% of your balance if all levels are met.
The upper 10 lines in red are our ‘sell’ intervals, which are each designed to open a short position worth 10% of your total balance. Let’s say if only 3 orders triggered, meaning you have spent 30% of your allocation, only the first 3 sell intervals will trigger.
When the bot is fully exposed, the cumulative position will be in the middle point between the highest and lowest entry. This means all 10 levels have been reached, via long or short position.
This bot is meant to be run in a Futures market. If used in a Spot market, this Grid Bot will sell 100% at the first sell interval.
- Top Resistance and Bottom Support are expecting a decimal. For example, use “37500.0” instead of “37500”.
- Grid Interval Percentage defines the spacing between each level. If using 10 lines in each direction, long and short for a total of 20, you’ll want to enter “10.0”. This input requires a decimal.
- How many lines? Is the number of levels you want for each direction, long and short.
- Max Buy determines how much to spend at each level. If you leave this at the default 100%, the Grid Bot will only buy once before waiting to sell. We recommend you set this according to the number of grid lines used. So 10 grid lines divided by 100% is a max buy of 10% per grid line.
- Stop Loss should be used to protect yourself in moments where price falls out of your Grid Bot’s range.
Long-Only Grid Bot
This version lets you specify the number of grid lines you’d like to use, with one sell threshold. The script allows up to 10 buy lines, with one sell line. You’ll notice too that just like our long-short grid bot, the long-only grid bot limits buy orders to once per line.
The inputs are the same as mentioned above, with the Long-Short Grid Bot, except there’s no need to set a Max Buy. That’s because we calculate the required order size. You can find this in our public library, with commented code, as Grid Bot – Long Only.
Short-Only Grid Bot
The opposite of our Long-Only Grid Bot described above, the Short-Only Grid Bot opens short positions as price increases. It’s strongly recommended to set a stop-loss.
Keep in mind that because we are opening short positions, this will only work on Futures markets. You can find this in our public library, with commented code, as Grid Bot – Short Only Grid Bot.
Who is this for?
Grid Bots benefit from clearly defined supports and resistance. Our Long-Only and Short-Only variants prioritize taking profits early, albeit with lower potential returns. A more careful trader may enjoy this configuration the most. Those who want a bit more involvement may prefer the Long-Short Grid Bot, which can profit in both directions.
What’s neat about running a Grid Bot on Tuned is the opportunity to train yourself and find optimal setups. You can do this by scrolling back to a random point in time, and without looking ahead, try to anticipate support and resistance for your gridbot.
With that we hope you’ll enjoy using our Grid Bot, and now with the script in hand you’re free to tailor it.