Trading grid

The trading grid is a key parameter of the bot. Without the grid, trading is not possible. In its essence, the trading grid is a plan of actions when the rate changes. The grid is defined by a set of lines (or rows), each of which is defined by the following key parameters:

  • «Buy price» - the price at which the BUY orders will be placed
  • «Sell price» - the price at which the SELL orders will be placed
  • «Start order type» - specifies which order was the first BUY or SELL. The procedures of correct order placing and profit fixing by pairs of trades depend on this parameter.
  • «Start order date» - date of placing the start order for the gridline. It affects the calculation of profitability.
  • «Start in SELL orders» - volume of funds placed in sell orders at the start.
  • «Start in BUY orders» - volume of funds, placed in buy orders at the start

 

The window with the trading grid setup looks like this:
In addition to the main columns, the window contains columns:
  • «№» - sequence number of the row for this bot
  • «Status» - a column for displaying the status of the row. There are the following options:
    • Indicates that this line will be the nearest to the order triggering if the rate goes up
    • Indicates that this line will be the nearest to the order triggering if the rate goes down
    • Indicates that there are warnings on the line. Additionally, a brief warning text is displayed, for example, "No orders" - denotes that there is an enabled grid line, but there are no orders placed on it on the exchange. It is necessary to check the settings and errors and correct the problem manually. Sometimes the warning appears due to an error, sometimes due to problems with communication with the exchange, sometimes with the loading of the exchange.
  • «Line is active» - means, that the line is included in work, trade is carried out on it, orders are placed, availability of orders on an exchange is checked. If the flag is removed, trading and checks on the line are not carried out.
  • «In position» - a calculation field, which reflects the pairing of orders. If the current order on the exchange by type matches with the starting order, the field will be "False", if different, then "True".
  • «In orders SELL» - the amount in SELL orders on the exchange at the moment
  • «In orders BUY» - the amount in BUY orders on the exchange at the moment
  • «Set SELL» - the field for displaying the intermediary amount to be set in SELL orders. The amount in this field is used to check the correctness of calculation, distribution or manual setting. If everything is correct and it is necessary to set the amount specified in this field, the user should press the button for setting start orders or the apply amounts button on the trading grid panel. After that, commands will be created to change the amounts on the exchange, which will be executed in the processing of the general queue of commands of the current bot.
  • «Set BUY» - a field for displaying the intermediate amount to be set in BUY orders. Usage is similar to the "Set SELL" field.
  • «ID» - code of the grid string in the database
  • «BUY correction» - the accumulated correction of the sum of purchase as a result of roundings. Occurs because of restrictions of the exchange on the size of the exposed order and on step of change of its size. It is critical for small order amounts The field is auxiliary and is used at the next calculation of the order amount.
  • «SELL correction» - accumulated correction of the selling amount as a result of rounding. This field appears due to limitations of the exchange on the order size and on the step of change in its size. This is critical for small order amounts. This field is auxiliary and is used in the next order amount calculation.
  • «Last order BUY size» - the last value of the placed BUY order. This field is auxiliary and is used when archiving the bot.
  • «Last order SELL size» - the last value of the placed SELL order. This field is auxiliary and is used when archiving the bot
The following buttons are located on the trading grid panel:
  • - adding a new grid line manually
  • - change the selected grid line manually. Identical to double-clicking on the grid line except for the fields "Row active", "Buy price", "Sell price", "Type on start" - these fields are edited in the table
  • - deleting the selected grid line
  • - updating the trade grid from the database
  • - starting the trading grid generator
  • - launching the setup and distribution of the trading grid sums wizard
  • - launching the cutting wizard for the trading grid sums
  • - turning on (setting the "Line is active" field to "True") the selected grid lines
  • - turning off (setting the "Line is active" field to "False") the selected grid lines
  • - placing start orders
  • -Applying new amounts to orders. Tasks are created to cancel orders placed (if they exist) and to place them with a new amount (if the amount is not zero).
  • - Cancellation of all orders in the exchange on the selected rows of the grid
  • - clearing of information in the fields "Start order date", "Start in SELL orders", "Start in BUY orders" on the selected grid lines
  • - clearing of information in the "Set SELL" and "Set BUY" fields on the selected grid lines
Creating a grid

When creating a bot, the trading grid is empty. There are two ways to create it:

  • Manual - each grid line is set manually
  • With the trading grid generator - the main way
Let's take a closer look at both variants.

Manual grid creation
To manually create a grid, use the following buttons on the grid panel. To create it, use the button . A window will open for entering information on the line:
 
The following fields must be filled out:
  • «№» - sequential number of the line in the grid
  • «Line is active» - sign of the active row in the grid
  • «Buy price» - the price at which the buy orders will be placed
  • «Sell price» - the price, at which the Sell orders will be placed
  • «Start order type» - SELL or BUY
  • «Start date» - date of trade start on this line. This field can be left blank, since it's filled in automatically, when placing the start order. If necessary, you can change it manually.
  • «Set SELL ()» - new amount of orders to sell. The base currency of the trading pair and the second currency of the trading pair are specified in brackets. When specifying the amounts, recalculation is performed automatically.
  • «Set BUY ()» - new amount of orders to buy. The base currency of the currency pair and the second currency are specified in brackets. When specifying the amounts, recalculation is performed automatically.
  • «Currency rates to USDT at start» - rates of base and second currency pair to USDT at the moment of start. It is set either manually, or when creating a start order, or when adding an amount to the grid line (the rate is averaged). It is used to calculate the field "At start USDT" in the table of bots.
  • «Set current exchange rates to USDT» - the button sets the current base and second currency rates to USDT.
 
Trade grid generator
For most cases, it is recommended to use the trading grid generator, which is much easier and faster than the manual method. To start the generator use the button   on the trading grid panel of the bot. The generator settings window opens::

The following parameters must be specified:

  • «Grid step (percentage)» - percentage of change for each next step.
  • «Grid range (percent)» - the half range in percent from the starting point up and down. The final range will be equal to twice the half range.
  • «Grid steps up» - the number of grid lines to be built up from the starting point. By default, the percentage, range, and starting point are calculated automatically when you specify the percentage, range, and starting point. It is possible to change manually to generate the exact number of steps.
  • «Grid steps down» - the number of grid lines to be built down from the starting point. By default, it is calculated automatically when percentage, range and starting point are specified. It is possible to change manually to generate the exact number of steps.
  • «Grid start point (price)» - the price from which all grid calculations are made.
  • «Get current price» button - sets the value of the current rate of the trading pair in the "Grid start point (price)" field.
  • «Clear grid first» - parameter that specifies whether to completely delete all existing bot grid lines before generation.
  • «Generate» button generates grid lines according to the specified parameters and performs merge of the current grid and the generated one. The merge is performed as follows: if the row of the new grid exists in the current grid by signs of equality of fields ("Sell price" and "Buy price"), then the existing row remains in the final grid, otherwise the new one is added. If the attribute "Clear grid first" is set to "True", then the merge result will always be equal to the new grid. After generation in the bot fields the parameters are saved:
    • «Trading grid start point (symbol price)»
    • «Trade grid step (%)»
    • «Trade grid range (% up and down from starting point)»
We recommend that they do not change throughout the life of the bot, to be able to complete (expand) the grid of the bot without shifting and complete cleaning, then all statistics will be correct.
 
Trading grid sums wizard
A trading grid created manually or through a generator is a basic entity, but not sufficient to start trading. It is necessary to define the amounts to be placed by the bot in the starting orders. This can be done manually through the "Set SELL" and "Set BUY" fields of each grid line or by using the wizard for allocating amounts using the button . The window with the settings of the sums allocation wizard (Amount editor) will open:

Use the "Get current balances" button to get the current balances on the account of the base and the second currency trading pair. Accordingly, the number of free coins, the number of coins already placed in orders and the total number will be displayed. Using the buttons  

you can transfer the appropriate number of coins to the setting field, correcting for rounding. This is the total amount that will be distributed evenly according to the following settings.

Apply to:

  • «All grid lines» - to all rows of the bot's trading grid
  • «All active grid lines» - to all rows of the bot's trading grid, where the "Line is active" field is set to "True"
  • «All selected grid lines» - to all rows of the bot's trading grid, which are selected in the trading grid before opening of the amount editor

 

Do with a new amount:

  • «Replace current amount» - for each line that hits the "Apply to" filter, the amount calculated as a result of the distribution will be replaced
  • «Add to current amount» - for each line that falls under the "Apply to" filter, the amount calculated as a result of the distribution will be added to the amount already placed in the orders
  • «Subtract from the current amount» - for each line that falls under the "Apply to" filter, the amount calculated as a result of the distribution will be subtracted from the amount already placed in the orders

Action with start sum:

  • «Do not change» - the starting amount will not be changed
  • «Change according to the action for the grid line» - the action will be taken from the "Do with new amount" parameter

Press the «Set amount» button to perform the allocation

The distribution result should be checked in the "Set SELL" and "Set BUY" columns. If the result is satisfactory, then to reflect it on the exchange, you must either set the start orders on the button   or apply with the button .
With this wizard it is possible both to allocate amounts at the start and to increase or decrease amounts later. When adding an amount to a line that already had a starting amount, and if the option to change the starting amount is selected "Change according to the action for the gridline", then the starting price will be averaged with the added amount at the current price. This is necessary for correct statistics. Averaging is not performed when decreasing the amounts.
 
Cutting the sums of the grid lines
Over time, it may be necessary to commit some of the profits of the running bot. For this purpose, there is a special mechanism "Grid line sum cutting", which is started by pressing the button . The following window will open:

The following fields must be configured in the parameters:

  • «Cut percent» - the percentage that will be calculated from the selected base to calculate the amount of cutting
  • «Cut base» - this is what the percentage will be calculated from. It can be:
    • Start sum - sum of start orders of the type that were at the start (BUY or SELL)
    • Open orders sum - amount of currently placed orders on the exchange
    • Profit (amount of open orders minus the amount of start orders)
  • «Action with start sum» - the parameter, which determines whether the sum of the start orders should be changed. Can take values:
    • Change
    • Do not change

For example, having specified the parameter "Change" it is possible to cut the start orders together with the exposed at the moment and then it will turn out that the sum exposed in the very beginning is withdrawn, but it is necessary to consider that thus percent of profitability in statistics will also change. IMPORTANT!!! - if you change the starting sum, it will be impossible to rollback the change.

  • «Apply to» is a parameter that shows to which rows of the grid you want to apply cutting. It can take a value of:
    • «All grid lines» - to all rows of the bot's trading grid
    • «All active grid lines» - to all rows of the bot's trading grid, where the "Line is active" field is set to "True"
    • «All selected grid lines» - to all rows of the bot's trading grid, which are selected in the trading grid before opening of the amount editor

To pre-calculate the cutting, click on the "Calculate" button. The table will display all rows to be cut, the cut amounts, the amounts before and after the start amounts and current orders are cut, and the released equivalent in USDT at the current exchange rate. The bottom line will be the sum of all lines.

It is necessary to check and make sure that you are satisfied with this cutting option, and then click the "Cut sum" button. The result will be a specified amount in the "Set SELL" and "Set BUY" fields of each row of the trading grid, as well as the changed starting amount:
If you are satisfied with the result, select the necessary lines and press the , if not satisfied, then clear the cut result with the . If the starting sum has been changed, it is impossible to undo the change.