INVITE-ONLY SCRIPT

linreg-gridbot

Atualizado
Linreg-GridBot
>release note version 1<

Introduction
This script is a powerful trading strategy tool designed to help users identify market reversal points and make smarter trading decisions using grid thinking.

Background
Traditional grid/martingale strategies have several drawbacks: inefficient use of capital, premature grid boundaries, and trading at fixed intervals, all of which significantly reduce profitability. Since, there is not a gridbot can trail-stop at each level, stay close with the trend, and do better capital usage, tradalive has created this advanced gridbot to address these issues, and enhance the profitability.

How does it work?
Imagine plotting closes on a graph, where the x-axis represents the time-intervals and the y-axis represents the price. Linear regression would fit a straight line through these points that best represents the trend of the data.

In this script utilize the built-in [Linreg] to find consecutive slopes at each moment, and combine them to a smooth trend line. When turning point censored, an entry is placed right after the next bar. Then the gridbot starts working, the upper limit and lower limit is calculated by built-in [ATR], for example 3 ATRs above and under the entry price.

There is a 0.2 trailing stop for each step level. Also, when built-in VWMA is rising, this script uses built-in ROC to find the average change of lookback length, then move the grid upwards accordingly.

Size trading is crucial, in gridbot all-in when beginning the trade is risky, because turning point does not guarantee a reversal market upcoming. As a grid trader, we believe the price is relatively cheap near the lower limit, and the price is relatively expensive near the upper limit. Properly sized orders help prevent overexposure and reduce the potential for significant losses.

Features
  • Trend Detection: Utilizes linear regression to differentiate between upward and downward trends, displaying them as (orange) trend lines on the chart.
  • Signal Generation: Provides buy or sell signals at reversal points, helping users trade at optimal times.
  • Adjustable Parameters: Allows users to customize different indicator parameters to fit various trading strategies.
  • Backtested Device Parameters (see appendix)


Grid Parameters
  • 🔃: Cyclic Trading
  • 💰: Capital Turnover Ratio (Grid capital difference per level: 0.5 to 2)
  • ⬆️ / ⬇️ Expected Number of Upward and Downward Grids.
    The minimum number of grids is three: one level above and below the current price.
    The maximum number of grids is seven: three levels above and below the current price.
  • 🧭: Trade Signal: Controls the trading direction, long or short;
  • 📏: Linear regression length value.
  • ⏳⌛Backtest Period: Set the time range for users to analyze the performance of the strategy over different periods.
  • Analytic Toolbox (upper right corner) :captura


Usage Instructions
  1. Add this script to your TradingView account.
  2. Apply the script to your chart.
  3. Adjust the parameters to fit your trading needs.
  4. Make trading decisions based on the buy and sell signals.
  5. Manually place orders on your trading platform using the parameters provided.
  6. Enter grid parameters according to the highest and lowest prices.
  7. Fill in the number of grid levels (the number of grids equals the number of upward grids plus the number of downward grids plus one).
  8. Set stop-loss and take-profit values.
  9. Alternatively, use a webhook to connect to your trading platform for automated trading.


Important Notes
  • This script currently only supports 4-hour and daily charts!
  • This script relies on historical data for calculations and may not be suitable for all market conditions.
  • Trading carries risks, so please use this script cautiously for trading decisions.
  • User has to update the backtest period, or else the strategy might not be seen.


Demostration
Phase one, the orange line is about to turn up. captura

Phase two, the reversal point is located, and right after the next bar start an entry of gridbot.
captura

Phase Three, the gridbot operates, once level touches, then a 0.2ATR trailing stop is applied on each step.
captura

Phase four, when vwma rises, the grid window follows it by the rate of change of lookback price. If vwma does not move up, then the grid boundaries remain.
captura

Phase five, either side when the current price breaks through the white limits, the gridbot stops. And the trading strategy is done for this round.
captura
Notas de Lançamento
Linreg-GridBot >Release Note Version 2<
  • Pine script version updated to v6
  • Added explanations of initial strategy settings
  • Added assumptions for using this strategy
  • Added analytic toolbox explanations


Strategy Setting
  1. This strategy is intended for use in the cryptocurrency market. Otherwise, users must conduct their own research before applying this script in other markets.
  2. Maker/Taker 0.05%: This is a common value for spot/leveraged commission fees on centralized exchange platforms (CEX).
  3. The unit of currency is based on USD.
  4. The initial capital in this script is 1000 USDT; users might adjust the capital accordingly.
  5. Depending on the connected CEX or asset liquidity, slippage may vary significantly. In this script, we accept a slippage of 10 points.


Assumptions
  • Each coin has its own cycle, meaning that a fixed length of linear regression (linreg) for all kinds of assets is naive. We suggest users fine-tune script parameters periodically.
  • The configuration is based on the performance of some outstanding coins within the year, which have fulfilled the following criteria:
  • High Sortino Ratio: >= 2
  • Small Maximum Drawdown: <= 20%
  • High Profitability: >= 30%
  • Our auto-configuration will be updated annually; users are responsible for verification. Users can verify the performance using TradingView (TV) built-in backtest tools or our quick skim analytic tool.
  • The buy-and-hold (BnH) strategy is adopted. Gridbot/martingale bot is commonly considered a BnH strategy. Fluctuations within the upper and lower limits of the bot should be accepted before opening an entry.
  • In our setting, the minimal PNL ratio of a trade is at least 1:1; one grid below and above the current price. If users do not agree with the trade, they can skip it based on their own observations.


Analytic Toolbox
  • Total Capital: 💰 Represented as a percentage, for instance, 1.6x of initial capital.
  • Maximum Drawdown: 📉 Represented as a percentage, for instance, 7.81% during the period observed.
  • Gridbot Profit of Current Trade: 🉐 Used to analyze the current grid profit compared to the initial capital. Outside the white background, NaN is shown, meaning no grid profit is generated.
  • Current Position: 💼 The trading capital (USD) used at the moment.
  • Sortino Ratio: 🎢 It is a performance metric used to evaluate the risk-adjusted return of an investment, focusing specifically on downside risk. Unlike the Sharpe Ratio, which considers both upside and downside volatility, the Sortino Ratio only penalizes negative returns.
  • Win Rate: 📊 The ratio of winning trades to closed trades, represented as a percentage.


Feel free to let me know if you need any further adjustments or clarifications!
Notas de Lançamento
Linreg-GridBot >Release Note Version 3<

  • Enhanced feature: 💸 Stop Loss setting


Description
  1. Hi, size trades and stops to only risk sustainable amounts of equity. Risking more than 5-10% on a trade is not typically considered viable. The function is built to fulfill the moderator's suggestion.
    *When open trade loss reaches the stop loss, this grid trading round is terminated.
    *💸 5% <= user input <= 10%, default is 5%.


Demonstration
Before Version 3, without advanced stop loss. Grid trading ends only when leaving the boundaries.
captura

Version 3, with advanced stop loss. Grid trading ends with respect to the stop loss setting.
captura

Users can actively check the unrealized profit/loss [%] on the strategy status bar (white circled).
captura
Cycleseducationalgridtradinglinregstatistics

Script sob convite

O acesso a este script é restrito aos usuários autorizados pelo autor e pode requerir pagamento. Você pode adicioná-lo a seus favoritos, mas só poderá utilizá-lo após solicitar permissão e obtê-la do autor. Contate tradalive para mais informações, ou siga as instruções do autor abaixo.

O TradingView não sugere pagar por um script e usá-lo, a menos que você confie 100% no seu autor e entenda como o script funciona. Em muitos casos, você pode encontrar uma boa alternativa de código aberto gratuita nos nossos Scripts da Comunidade.

Quer usar esse script no gráfico?

Aviso: por favor leia antes de solicitar acesso.

Também em:

Aviso legal