xxattaxx-DisDev

Grid Bot Auto

This script is an auto-adjusting grid bot simulator. This is an improved version of the original Grid Bot Simulator. The grid bot is best used for ranging/choppy markets. Prices are divided into grids, or trade zones, that will trigger signals each time a new zone is entered. During ranging markets, each transaction is followed by a “take profit.” As the market starts to trend, transactions are stacked (compare to DCA ), until the market consolidates. No signals are triggered above the Upper Limit or Below the Lower Limit. Unlike the previous version, the upper and lower limits are calculated automatically. Grid levels are determined by four factors: Smoothing, Laziness, Elasticity, and Grid Intervals.

Smoothing:
A moving average (or linear regression) is applied to each close price as a basis. Options for smoothing are Linear Regression, Simple Moving Average, Exponential Moving Average, Volume-Weighted Moving Average, Triple-Exponential Moving Average.

Laziness:
Laziness is the percentage change required to reach the next level. If laziness is 1.5, the price must move up or down by 1.5% before the grid will change. This concept is based on Alex Grover’s Efficient Trend Step. This allows the grids to be based on even price levels, as opposed to jagged moving averages.

Elasticity:
Elasticity is the degree of “stickiness” to the current price trend. If the smoothing line remains above (or below) the current grid center without reverting but still not enough to reach the next grid level, the grid line will start to curve toward the next grid level. Elasticity is added to (or subtracted from) the gridline by a factor of minimum system ticks for the current pair. Elasticity of zero will keep the gridlines horizontal. If elasticity is too high, the grid will distort.

Grid Intervals:
Grid intervals are the percentage of space between each grid.

Laziness = 4%, Elasticity = 0. Price must move at least 4% before reaching the next level. With zero elasticity, gridlines are straight.

Laziness = 5%, Elasticity = 100. For each bar at a new grid level, the grid will start “curve” toward the next price level (up if price is greater than the middle grid, down if less than middle grid). Elasticity is calculated by the user-inputted “Elasticity” multiplied by the minimum tick for the current pair (ELSTX = syminfo.mintick * iELSTX)

Try experimenting with different combinations of the Smoothing Length, Smoothing Type, Laziness, Elasticity, and Grid Intervals to find the optimum settings for each chart. Lower-priced pairs (e.g. XRP/ADA/DODGE) will require lower Elasticity. Also note that different exchanges may have different minimum tick values. For example, minimum tick for BITMEX:XBTUSD and BYBIT:BTCUSD is .5, but BINANCE:BTCUSDT and COINBASE:BTCUSD is .01.

 DODGEUSDT, 5min. Laziness: 4%, Elasticity 2.5

Number of Grids: 2. Laziness: 3.75%. Elasticity: 150. Grid Interval 2%.

Settings Overview

Smoothing Length: Smoothing period

Smoothing Type: Linear Regression, Simple Moving Average, Exponential Moving Average, Volume-Weighted Moving Average, Triple-Exponential Moving Average

Laziness: Percentage required for price to move until it reaches the next level. If price does not reach the next level (up or down), the grid will remain the same as previous grid (because it’s lazy).

Elasticity: Amount of curvature toward the next grid, based on the current price trend. As elasticity increases, gridlines will curve up or down by a factor of the number of ticks since the last grid change.

Grid Interval: Percent between grid levels.

Number of Grids: Number of grids to show.

Cooldown: Number of bars to wait to prevent consecutive signals.

Grid Line Transparency: Lower transparencies brighten the gridlines; higher transparencies dim the gridlines. To hide the gridlines completely, enter 100.

Fill Transparency: Lower transparencies brighten the fill box; higher transparencies dim the fill box. To hide the fill box completely, enter 100.

Signal Size: Make signal triangles large or small.

Reset Buy/Sell Index When Grids Change: When a new grid is formed, resetting the index may prevent false signals (experimental)

Use Highs/Lows for Signals: If enabled, signals are triggered as soon as the price touches the next zone. If disabled, signals are triggered after bar closes. Enable this for “Once Per Bar alerts. Disable for “Once Per Bar Close” alerts.

Show Min Tick: If checked, syminfo.mintick is displayed in upper-righthand corner. Useful for estimating Laziness.

Reverse Fill Colors: Default fill for fill boxes is green after buy and red after sell. Check this box to reverse.

Note: The Grid Bot Simulator scripts are experimental and works in progress. Please feel free to comment or contact me if you have suggestions/complaints.






Release Notes:
Cleaned code
Release Notes:
Added market direction filter. Bot will skip every other signal against market direction (up or down).
Release Notes:
Updated to Pinescript version 5.

USDT(TRC20):THb7BFnXP3FceQDSoLqG8DiE7KrfjZLJn7
USDT(ERC20):0xe5f4aab4dd0f297843146d51605010bf2c2f83e7
BTC:19VVs5MGYi9gWDoHZVwqpiXfqao3WpePRY
Link:0xe5f4aab4dd0f297843146d51605010bf2c2f83e7
ETH(ERC20): 0xe5f4aab4dd0f297843146d51605010bf2c2
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?