OPEN-SOURCE SCRIPT
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.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.