thequantscience

GRID SPOT TRADING ALGORITHM - GRID BOT TRADING STRATEGY

GRID SPOT TRADING ALGORITHM : LONG ONLY STRATEGY OPEN SOURCE

This is a long only strategy for spot assets.

HOW IT WORKS
Grid trading is a trading strategy where an investor creates a so-called "price grid". The basic idea of the strategy is to repeatedly buy at the pre-specified price and then wait for the price to rise above that level and then sell the position (and vice versa with shorting or hedging).

FEATURES
Grids: This algorithm has a total of 10 grids.
Take profit: The trader can increase or decrease the distance between the grids from the User Interface panel, the distance between one grid and another represents the take profit.
Management: The algorithm buys 10% of the capital every time the price breaks down a grid and sells during a rise to the next higher grid. The initial capital is invested in 10 sizes which represent 10% of the capital per trade.
Stop Loss: The algorithm knows no stop loss as long as it is not activated from the User Interface panel. By activating the stop loss from the User Interface panel the algorithm will insert a close condition on all trades which will be calculated from the last lower grid.
Trades: Trades are opened only if the price is within the grid. If the market leaves the grid the algorithm will not buy new positions or sell new positions.
Optimal market conditions: The favorable market for this algorithm is the sideways market.

LIMITATIONS OF THE MODEL
The trader must take into account that this is a static model. It only works perfectly well if the market is in a sideways phase and incurs heavy losses if the market takes a downward trend. The model is unusable for an uptrend. The trader must therefore carefully analyze the market where he intends to use this strategy, making sure that the price is in a sideways phase.

USES
Indispensable research and backtesting tool for those using bots for their investments. The algorithm produces a backtesting of the strategy for past history. It is used by professional traders to understand if this strategy has been profitable on a market and what parameters to use for bots using this strategy (Kucoin, Binance etc.).

If you would like to develop your own algorithm with customized conditions based on a grid strategy, please contact us.

If you need help in using this tool, please contact us without hesitation.
Release Notes:
UPDATE JULY 7, 2022

A lot of users have congratulated and motivated us, calling this algorithm one of the best for the grid models in Trading View. We decided to improve it, following the feedback of our users. Our grid bot algorithm offer accurate backtesting and allow you to create custom grids that you can then easily apply to third-party services such as Bitsgap or others.

1. Performance bug fix: the strategy had several output issues. The Trading View performance generator was offering an inappropriate calculation for this type of model. Therefore, we integrated a table showing the performance of the strategy correctly.

2. Improved User Interface: we boost the code and created a better user experience. Descriptions and confirmation tabs have been added. Many users experienced difficulty in setting up on the algorithm chart. This update has eliminated this issue definitely.

3. Grid improvement: the design of the grid has been improved, creating a refined design tool. The old grid has been replaced with a new one that has a lighter and more intuitive design.

4. Update of functions that will be deprecated: functions that will be deprecated in future updates of Pine Script have been removed. This will allow everyone to have a super tool that will run with any problem during next Pine Script updates.

A second update will be released in the coming months.
In the next update we plan to include backtesting for the short strategy. Then any user will be able to change the strategy backtesting from long to short and vice versa in a few clicks via the user interface. In these months we will collect feedback from our users, this allows us to understand how to continue to develop this algorithm for the better way.

Please contribute to grow this great algorithm within the community. If you found it useful leave feedback in the comments, this will help us to a better improve.
Release Notes:
Hello guys, the new update is finally made !

We worked hard to create a professional template to help traders to test 3commas grid strategy, using a customized entry trigger.

The default code is set to an entry trigger based on the overbought RSI indicator. You can enter your own condition in your code and test the performance of your strategy easily now. To enter your own entry condition, simply describe your function within the local function
 TriggerGrid( 
(string no. 198). Automatically the grid will be generated when the trigger will be true.

Two different grids: we have included two different grids, one with 10 levels and the other with 20 levels. You can easily choose one of these from the user interface.

Destroy input: we have entered a destruction level. By default it is deactivated, you can activate it and enter the stop loss price. When the price breaks the stop level, the destruction grid will close all open orders.

Improved visual design: we improved the graphics by facilitating a better understanding of the algorithm workflow by the user.

How exactly it works, let's understand it with an example.

Imagine we use the 20-level grid, so each order will be placed when the entry trigger is true. Each trade is executed when the price touches a level. No new orders are placed until the last order is executed. The trade is closed symmetrically. In this case, the first trade will buy at level number 11 and sell at number 10, the second trade will buy at level number 12 and sell at number 9, the third trade will buy at level number 13 and sell at number 8 and so on..

Contact us for any information.
Release Notes:
House Of Rules Compliant Script Update
Release Notes:
Updated 3.0 : Fixing date period function. Now users can use this algorithm with date period backtesting, without bugs.
Release Notes:
This software has been deprecated. Now, you can use the new version Grid Spot Trading Algorithm V2.

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?