INVITE-ONLY SCRIPT

linreg-gridbot

Cập nhật
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) :ảnh chụp nhanh


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. ảnh chụp nhanh

Phase two, the reversal point is located, and right after the next bar start an entry of gridbot.
ảnh chụp nhanh

Phase Three, the gridbot operates, once level touches, then a 0.2ATR trailing stop is applied on each step.
ảnh chụp nhanh

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.
ảnh chụp nhanh

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.
ảnh chụp nhanh
Phát hành các Ghi chú
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!
Phát hành các Ghi chú
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.
ảnh chụp nhanh

Version 3, with advanced stop loss. Grid trading ends with respect to the stop loss setting.
ảnh chụp nhanh

Users can actively check the unrealized profit/loss [%] on the strategy status bar (white circled).
ảnh chụp nhanh
Cycleseducationalgridtradinglinregstatistics

Tập lệnh chỉ hiển thị cho người được mời

Quyền truy cập vào tập lệnh này bị hạn chế đối với người dùng được tác giả ủy quyền và thường yêu cầu thanh toán. Bạn có thể thêm nó vào mục yêu thích của mình, nhưng bạn sẽ chỉ có thể sử dụng nó sau khi yêu cầu sự cho phép từ tác giả. Liên hệ tradalive để thêm thông tin, hoặc làm theo hướng dẫn của tác giả bên dưới.

TradingView gợi ý bạn không trả tiền để sử dụng tập lệnh trừ khi bạn tin tưởng 100% vào tác giả của tập lệnh và hiểu cách hoạt động của tập lệnh. Trong nhiều trường hợp, bạn có thể tìm thấy giải pháp thay thế nguồn mở tốt miễn phí trong Tập lệnh cộng đồng của chúng tôi.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?

Cảnh báo: vui lòng đọc trước khi yêu cầu quyền truy cập.

Ngoài ra, trên:

Thông báo miễn trừ trách nhiệm