OPEN-SOURCE SCRIPT
Cập nhật Simple Grid Trading v1.0 [PUCHON]

Simple Grid Trading v1.0 [PUCHON]
Overview
This is a Long-Only Grid Trading Strategy developed in Pine Script v6 for TradingView. It is designed to profit from market volatility by placing a series of Buy Limit orders at predefined price levels. As the price drops, the strategy accumulates positions. As the price rises, it sells these positions at a profit.
Features
Dashboard Metrics
The dashboard (default: Bottom Right) provides a quick snapshot of the strategy's performance:
Strategy Settings (Inputs)
Grid Settings
Dashboard Settings
How It Works
Disclaimer
This script is for educational and backtesting purposes only. Grid trading involves significant risk, especially in strong trending markets where the price may move outside your grid range. Always use proper risk management.
Overview
This is a Long-Only Grid Trading Strategy developed in Pine Script v6 for TradingView. It is designed to profit from market volatility by placing a series of Buy Limit orders at predefined price levels. As the price drops, the strategy accumulates positions. As the price rises, it sells these positions at a profit.
Features
- Grid Types: Supports both Arithmetic (equal price spacing) and Geometric (equal percentage spacing) grids.
- Flexible Order Management: Uses strategy.order for precise control and prevents duplicate orders at the same level.
- Performance Dashboard: A real-time table displaying key metrics like Capital, Cashflow, and Drawdown.
- Advanced Metrics: Includes Max Drawdown (MaxDD), Avg Monthly Return, and CAGR calculations.
- Customizable: Fully adjustable price range, grid lines, and lot size.
Dashboard Metrics
The dashboard (default: Bottom Right) provides a quick snapshot of the strategy's performance:
- Initial Capital: The starting capital defined in the strategy settings.
- Lot Size: The fixed quantity of assets purchased per grid level.
- Avg. Profit per Grid: The average realized profit for each closed trade.
- Cashflow: The total realized net profit (closed trades only).
- MaxDD: Maximum Drawdown. The largest percentage drop in equity (realized + unrealized) from a peak.
- Avg Monthly Return: The average percentage return generated per month.
- CAGR: Compound Annual Growth Rate. The mean annual growth rate of the investment over the specified time period.
Strategy Settings (Inputs)
Grid Settings
- Upper Price: The highest price level for the grid.
- Lower Price: The lowest price level for the grid.
- Number of Grid Lines: The total number of levels (lines) in the grid.
- Grid Type:
Arithmetic: Distance between lines is fixed in price terms (e.g., $10, $20, $30).
Geometric: Distance between lines is fixed in percentage terms (e.g., 1%, 2%, 3%). - Lot Size: The fixed amount of the asset to buy at each level.
Dashboard Settings
- Show Dashboard: Toggle to hide/show the performance table.
- Position: Choose where the dashboard appears on the chart (e.g., Bottom Right, Top Left).
How It Works
- Initialization: On the first bar, the script calculates the price levels based on your Upper/Lower price and Grid Type.
- Entry Logic:
The strategy places Buy Limit orders at every grid level below the current price.
It checks if a position already exists at a specific level to avoid "stacking" multiple orders on the same line. - Exit Logic:
For every Buy order, a corresponding Sell Limit (Take Profit) order is placed at the next higher grid level. - MaxDD Calculation:
- The script continuously tracks the highest equity peak.
- It calculates the drawdown on every bar (including intra-bar movements) to ensure accuracy.
- Displayed as a percentage (e.g., 5.25%).
- The script continuously tracks the highest equity peak.
Disclaimer
This script is for educational and backtesting purposes only. Grid trading involves significant risk, especially in strong trending markets where the price may move outside your grid range. Always use proper risk management.
Phát hành các Ghi chú
Update v1.1.0- Removed Lot Size Input: The strategy now uses the default order size defined in the Strategy Properties (Settings -> Properties -> Order Size). This allows for more flexible position sizing management directly from the TradingView interface.
- Dashboard Update: Removed the "Lot Size" row and added a "Version" indicator.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội Quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội Quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.