pinescript-mcp 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. pinescript_mcp-0.1.0/.gitignore +222 -0
  2. pinescript_mcp-0.1.0/LICENSE +21 -0
  3. pinescript_mcp-0.1.0/PKG-INFO +121 -0
  4. pinescript_mcp-0.1.0/README.md +98 -0
  5. pinescript_mcp-0.1.0/pyproject.toml +44 -0
  6. pinescript_mcp-0.1.0/src/pinescript_mcp/__init__.py +7 -0
  7. pinescript_mcp-0.1.0/src/pinescript_mcp/__main__.py +6 -0
  8. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/LLM_MANIFEST.md +96 -0
  9. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/concepts/colors_and_display.md +574 -0
  10. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/concepts/common_errors.md +550 -0
  11. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/concepts/execution_model.md +1059 -0
  12. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/concepts/methods.md +543 -0
  13. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/concepts/objects.md +349 -0
  14. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/concepts/timeframes.md +73 -0
  15. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/pine_v6_functions.json +488 -0
  16. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/reference/annotations.md +229 -0
  17. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/reference/constants.md +1694 -0
  18. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/reference/functions/collections.md +2793 -0
  19. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/reference/functions/drawing.md +1082 -0
  20. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/reference/functions/general.md +1892 -0
  21. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/reference/functions/request.md +232 -0
  22. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/reference/functions/strategy.md +1517 -0
  23. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/reference/functions/ta.md +1225 -0
  24. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/reference/keywords.md +487 -0
  25. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/reference/operators.md +311 -0
  26. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/reference/pine_v6_cheatsheet.md +183 -0
  27. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/reference/types.md +405 -0
  28. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/reference/variables.md +2272 -0
  29. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/visuals/backgrounds.md +110 -0
  30. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/visuals/bar_coloring.md +35 -0
  31. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/visuals/bar_plotting.md +93 -0
  32. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/visuals/colors.md +574 -0
  33. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/visuals/fills.md +497 -0
  34. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/visuals/levels.md +91 -0
  35. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/visuals/lines_and_boxes.md +1252 -0
  36. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/visuals/overview.md +563 -0
  37. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/visuals/plots.md +390 -0
  38. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/visuals/tables.md +207 -0
  39. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/visuals/texts_and_shapes.md +862 -0
  40. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/writing_scripts/debugging.md +1943 -0
  41. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/writing_scripts/limitations.md +457 -0
  42. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/writing_scripts/profiling_and_optimization.md +2016 -0
  43. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/writing_scripts/publishing_scripts.md +327 -0
  44. pinescript_mcp-0.1.0/src/pinescript_mcp/docs/writing_scripts/style_guide.md +245 -0
  45. pinescript_mcp-0.1.0/src/pinescript_mcp/server.py +570 -0
@@ -0,0 +1,222 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .tv_auth_state.json
154
+ .venv
155
+ env/
156
+ venv/
157
+ ENV/
158
+ env.bak/
159
+ venv.bak/
160
+
161
+ # Spyder project settings
162
+ .spyderproject
163
+ .spyproject
164
+
165
+ # Rope project settings
166
+ .ropeproject
167
+
168
+ # mkdocs documentation
169
+ /site
170
+
171
+ # mypy
172
+ .mypy_cache/
173
+ .dmypy.json
174
+ dmypy.json
175
+
176
+ # Pyre type checker
177
+ .pyre/
178
+
179
+ # pytype static type analyzer
180
+ .pytype/
181
+
182
+ # Cython debug symbols
183
+ cython_debug/
184
+
185
+ # PyCharm
186
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
187
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
188
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
189
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
190
+ # .idea/
191
+
192
+ # Abstra
193
+ # Abstra is an AI-powered process automation framework.
194
+ # Ignore directories containing user credentials, local state, and settings.
195
+ # Learn more at https://abstra.io/docs
196
+ .abstra/
197
+
198
+ # Visual Studio Code
199
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
200
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
201
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
202
+ # you could uncomment the following to ignore the entire vscode folder
203
+ # .vscode/
204
+
205
+ # Ruff stuff:
206
+ .ruff_cache/
207
+
208
+ # PyPI configuration file
209
+ .pypirc
210
+
211
+ # Marimo
212
+ marimo/_static/
213
+ marimo/_lsp/
214
+ __marimo__/
215
+
216
+ # Streamlit
217
+ .streamlit/secrets.toml
218
+
219
+ # Project-specific
220
+ research/output/
221
+ .python-version
222
+ uv.lock
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 bch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,121 @@
1
+ Metadata-Version: 2.4
2
+ Name: pinescript-mcp
3
+ Version: 0.1.0
4
+ Summary: MCP server providing Pine Script v6 documentation for AI assistants
5
+ Project-URL: Homepage, https://github.com/bch/pinescript-mcp
6
+ Project-URL: Documentation, https://github.com/bch/pinescript-mcp#readme
7
+ Project-URL: Repository, https://github.com/bch/pinescript-mcp
8
+ Author: bch
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: ai,claude,documentation,mcp,pine-script,tradingview
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Software Development :: Documentation
20
+ Requires-Python: >=3.10
21
+ Requires-Dist: mcp>=1.26.0
22
+ Description-Content-Type: text/markdown
23
+
24
+ # pinescript-mcp
25
+
26
+ MCP server providing Pine Script v6 documentation for AI assistants (Claude, etc.).
27
+
28
+ Enables AI to:
29
+ - Look up Pine Script functions and validate syntax
30
+ - Access official documentation for indicators, strategies, and visuals
31
+ - Understand Pine Script concepts (execution model, repainting, etc.)
32
+ - Generate correct v6 code with proper function references
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ pip install pinescript-mcp
38
+ ```
39
+
40
+ ## Usage with Claude Desktop
41
+
42
+ Add to `~/.config/claude/claude_desktop_config.json`:
43
+
44
+ ```json
45
+ {
46
+ "mcpServers": {
47
+ "pinescript-docs": {
48
+ "command": "pinescript-mcp"
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+ ## Usage with Claude Code
55
+
56
+ Add to `.mcp.json` in your project:
57
+
58
+ ```json
59
+ {
60
+ "mcpServers": {
61
+ "pinescript-docs": {
62
+ "type": "stdio",
63
+ "command": "pinescript-mcp"
64
+ }
65
+ }
66
+ }
67
+ ```
68
+
69
+ ## Available Tools
70
+
71
+ | Tool | Description |
72
+ |------|-------------|
73
+ | `list_docs()` | List all documentation files with descriptions |
74
+ | `get_doc(path)` | Read a specific documentation file |
75
+ | `search_docs(query)` | Full-text search across all docs |
76
+ | `get_functions(namespace)` | List valid functions (ta, strategy, etc.) |
77
+ | `validate_function(name)` | Check if a function exists in Pine v6 |
78
+ | `resolve_topic(query)` | Map a question to relevant docs |
79
+ | `get_manifest()` | Get routing guidance for topics |
80
+
81
+ ## Example Queries
82
+
83
+ - "How do I create a trailing stop in Pine Script?"
84
+ - "What's the difference between var and varip?"
85
+ - "Is ta.supertrend a valid function?"
86
+ - "How do I avoid repainting with request.security?"
87
+
88
+ ## Documentation Coverage
89
+
90
+ The server bundles comprehensive Pine Script v6 documentation:
91
+
92
+ - **Concepts**: Execution model, timeframes, colors, methods, objects, common errors
93
+ - **Reference**: Types, variables, constants, keywords, operators, annotations
94
+ - **Functions**: Technical analysis (ta.*), strategies, requests, drawings, collections
95
+ - **Visuals**: Plots, fills, shapes, tables, lines, boxes, backgrounds
96
+ - **Writing Scripts**: Style guide, debugging, optimization, limitations
97
+
98
+ ## Why Use This?
99
+
100
+ AI models often hallucinate Pine Script functions or use deprecated v5 syntax. This MCP server grounds the AI in actual v6 documentation, preventing:
101
+
102
+ - Made-up function names (e.g., `ta.supertrend` doesn't exist)
103
+ - Deprecated syntax from v4/v5
104
+ - Incorrect parameter orders
105
+ - Missing required arguments
106
+
107
+ ## Development
108
+
109
+ ```bash
110
+ # Clone and install locally
111
+ git clone https://github.com/bch/pinescript-mcp
112
+ cd pinescript-mcp
113
+ pip install -e .
114
+
115
+ # Run the server
116
+ pinescript-mcp
117
+ ```
118
+
119
+ ## License
120
+
121
+ MIT
@@ -0,0 +1,98 @@
1
+ # pinescript-mcp
2
+
3
+ MCP server providing Pine Script v6 documentation for AI assistants (Claude, etc.).
4
+
5
+ Enables AI to:
6
+ - Look up Pine Script functions and validate syntax
7
+ - Access official documentation for indicators, strategies, and visuals
8
+ - Understand Pine Script concepts (execution model, repainting, etc.)
9
+ - Generate correct v6 code with proper function references
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ pip install pinescript-mcp
15
+ ```
16
+
17
+ ## Usage with Claude Desktop
18
+
19
+ Add to `~/.config/claude/claude_desktop_config.json`:
20
+
21
+ ```json
22
+ {
23
+ "mcpServers": {
24
+ "pinescript-docs": {
25
+ "command": "pinescript-mcp"
26
+ }
27
+ }
28
+ }
29
+ ```
30
+
31
+ ## Usage with Claude Code
32
+
33
+ Add to `.mcp.json` in your project:
34
+
35
+ ```json
36
+ {
37
+ "mcpServers": {
38
+ "pinescript-docs": {
39
+ "type": "stdio",
40
+ "command": "pinescript-mcp"
41
+ }
42
+ }
43
+ }
44
+ ```
45
+
46
+ ## Available Tools
47
+
48
+ | Tool | Description |
49
+ |------|-------------|
50
+ | `list_docs()` | List all documentation files with descriptions |
51
+ | `get_doc(path)` | Read a specific documentation file |
52
+ | `search_docs(query)` | Full-text search across all docs |
53
+ | `get_functions(namespace)` | List valid functions (ta, strategy, etc.) |
54
+ | `validate_function(name)` | Check if a function exists in Pine v6 |
55
+ | `resolve_topic(query)` | Map a question to relevant docs |
56
+ | `get_manifest()` | Get routing guidance for topics |
57
+
58
+ ## Example Queries
59
+
60
+ - "How do I create a trailing stop in Pine Script?"
61
+ - "What's the difference between var and varip?"
62
+ - "Is ta.supertrend a valid function?"
63
+ - "How do I avoid repainting with request.security?"
64
+
65
+ ## Documentation Coverage
66
+
67
+ The server bundles comprehensive Pine Script v6 documentation:
68
+
69
+ - **Concepts**: Execution model, timeframes, colors, methods, objects, common errors
70
+ - **Reference**: Types, variables, constants, keywords, operators, annotations
71
+ - **Functions**: Technical analysis (ta.*), strategies, requests, drawings, collections
72
+ - **Visuals**: Plots, fills, shapes, tables, lines, boxes, backgrounds
73
+ - **Writing Scripts**: Style guide, debugging, optimization, limitations
74
+
75
+ ## Why Use This?
76
+
77
+ AI models often hallucinate Pine Script functions or use deprecated v5 syntax. This MCP server grounds the AI in actual v6 documentation, preventing:
78
+
79
+ - Made-up function names (e.g., `ta.supertrend` doesn't exist)
80
+ - Deprecated syntax from v4/v5
81
+ - Incorrect parameter orders
82
+ - Missing required arguments
83
+
84
+ ## Development
85
+
86
+ ```bash
87
+ # Clone and install locally
88
+ git clone https://github.com/bch/pinescript-mcp
89
+ cd pinescript-mcp
90
+ pip install -e .
91
+
92
+ # Run the server
93
+ pinescript-mcp
94
+ ```
95
+
96
+ ## License
97
+
98
+ MIT
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "pinescript-mcp"
7
+ version = "0.1.0"
8
+ description = "MCP server providing Pine Script v6 documentation for AI assistants"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.10"
12
+ authors = [{ name = "bch" }]
13
+ keywords = ["mcp", "pine-script", "tradingview", "documentation", "ai", "claude"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Programming Language :: Python :: 3.10",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Programming Language :: Python :: 3.13",
22
+ "Topic :: Software Development :: Documentation",
23
+ ]
24
+ dependencies = [
25
+ "mcp>=1.26.0",
26
+ ]
27
+
28
+ [project.urls]
29
+ Homepage = "https://github.com/bch/pinescript-mcp"
30
+ Documentation = "https://github.com/bch/pinescript-mcp#readme"
31
+ Repository = "https://github.com/bch/pinescript-mcp"
32
+
33
+ [project.scripts]
34
+ pinescript-mcp = "pinescript_mcp.server:main"
35
+
36
+ [tool.hatch.build.targets.wheel]
37
+ packages = ["src/pinescript_mcp"]
38
+
39
+ [tool.hatch.build.targets.sdist]
40
+ include = [
41
+ "src/pinescript_mcp/**/*.py",
42
+ "src/pinescript_mcp/**/*.md",
43
+ "src/pinescript_mcp/**/*.json",
44
+ ]
@@ -0,0 +1,7 @@
1
+ """Pine Script v6 Documentation MCP Server.
2
+
3
+ Provides tools to list, search, and read Pine Script v6 documentation
4
+ for use with AI assistants like Claude.
5
+ """
6
+
7
+ __version__ = "0.1.0"
@@ -0,0 +1,6 @@
1
+ """Entry point for python -m pinescript_mcp."""
2
+
3
+ from .server import main
4
+
5
+ if __name__ == "__main__":
6
+ main()
@@ -0,0 +1,96 @@
1
+ # Pine Script v6 Documentation Manifest
2
+
3
+ **Purpose:** This file acts as a directory map for Large Language Models (LLMs). Use this manifest to determine which specific documentation files to retrieve based on the user's request.
4
+
5
+ **Protocol:** 1. Identify the user's intent (e.g., "Drawing a line", "Calculating RSI", "Backtesting").
6
+ 2. Locate the relevant file path below.
7
+ 3. Retrieve ONLY that file to conserve context window.
8
+
9
+ ## 1. Syntax and Core Concepts
10
+
11
+ *Use these files when the user asks about language mechanics, execution flow, or type errors.*
12
+
13
+ * **`concepts/execution_model.md`**
14
+ * **Content:** How the script executes bar-by-bar, historical vs. real-time context, and the `var` keyword.
15
+ * **Keywords:** `barstate`, `history`, `realtime`, `calc_on_every_tick`, `var`, `varip`.
16
+
17
+ * **`concepts/timeframes.md`**
18
+ * **Content:** Handling multi-timeframe data and preventing repainting.
19
+ * **Keywords:** `request.security`, `timeframe.period`, `repainting`, `HTF`.
20
+
21
+ * **`concepts/colors_and_display.md`**
22
+ * **Content:** Defining colors, gradients, and transparency.
23
+ * **Keywords:** `color.new`, `color.from_gradient`, `bgcolor`.
24
+
25
+ * **`concepts/common_errors.md`**
26
+ * **Content:** Explanations for common runtime and compile-time errors.
27
+ * **Keywords:** "Series string", "Undeclared identifier", "max_bars_back".
28
+
29
+ * **`reference/pine_v6_cheatsheet.md`**
30
+ * **Content:** Compact reference of ALL valid v6 functions, namespaces, built-in variables, constants, and common pitfalls. Always include this file.
31
+ * **Keywords:** `cheatsheet`, `valid functions`, `namespaces`, `v6 reference`, `validation`.
32
+
33
+ ## 2. API Reference (The Dictionary)
34
+
35
+ *Use these files for looking up built-in variables, constants, and keywords.*
36
+
37
+ * **`reference/variables.md`**
38
+ * **Content:** Built-in read-only variables regarding the bar, symbol, or status.
39
+ * **Keywords:** `open`, `high`, `low`, `close`, `volume`, `time`, `syminfo.ticker`, `timeframe.multiplier`, `bar_index`.
40
+
41
+ * **`reference/constants.md`**
42
+ * **Content:** Fixed constants used as arguments for functions.
43
+ * **Keywords:** `color.red`, `shape.triangle`, `plot.style_line`, `size.small`, `alert.freq_once_per_bar`.
44
+
45
+ * **`reference/types.md`**
46
+ * **Content:** Data type definitions and type-casting functions.
47
+ * **Keywords:** `int`, `float`, `bool`, `color`, `string`, `line`, `label`, `box`, `simple`, `series`, `input`.
48
+
49
+ * **`reference/keywords.md`**
50
+ * **Content:** Language keywords and control structures.
51
+ * **Keywords:** `if`, `else`, `switch`, `for`, `while`, `export`, `import`, `method`.
52
+
53
+ ## 3. Function Reference (By Namespace)
54
+
55
+ *Use these files to find syntax for specific function calls.*
56
+
57
+ * **`reference/functions/ta.md` (Technical Analysis)**
58
+ * **Content:** Math for indicators and signal generation.
59
+ * **Keywords:** `ta.rsi`, `ta.sma`, `ta.ema`, `ta.macd`, `ta.crossover`, `ta.lowest`, `ta.highest`, `ta.pivot`.
60
+
61
+ * **`reference/functions/strategy.md` (Backtesting)**
62
+ * **Content:** Strategy testing engine, orders, and trade management.
63
+ * **Keywords:** `strategy.entry`, `strategy.close`, `strategy.exit`, `strategy.position_size`, `strategy.equity`, `strategy.risk`.
64
+
65
+ * **`reference/functions/request.md` (External Data)**
66
+ * **Content:** Requesting data from other symbols, financial data, or seeds.
67
+ * **Keywords:** `request.security`, `request.financial`, `request.seed`, `request.currency_rate`.
68
+
69
+ * **`reference/functions/drawing.md` (Visuals)**
70
+ * **Content:** Plotting data on the chart and drawing geometric shapes.
71
+ * **Keywords:** `plot`, `plotshape`, `plotchar`, `line.new`, `box.new`, `label.new`, `polyline.new`, `fill`.
72
+
73
+ * **`reference/functions/collections.md` (Arrays, Maps, Matrices)**
74
+ * **Content:** Advanced data structures for complex logic.
75
+ * **Keywords:** `array.new`, `array.push`, `matrix.new`, `matrix.mult`, `map.new`, `map.put`.
76
+
77
+ * **`reference/functions/general.md` (Math, Strings, Inputs)**
78
+ * **Content:** Core math, string manipulation, and user inputs.
79
+ * **Keywords:** `math.abs`, `math.round`, `str.tostring`, `str.format`, `input.int`, `input.bool`, `alert()`.
80
+
81
+ ## 🧭 Routing Logic for LLMs
82
+
83
+ * **IF** user asks "Write an RSI indicator":
84
+ * retrieve `reference/functions/ta.md` (for RSI math)
85
+ * retrieve `reference/functions/drawing.md` (for `plot` and `hline`)
86
+
87
+ * **IF** user asks "Create a moving average crossover strategy":
88
+ * retrieve `reference/functions/ta.md` (for `ta.crossover`)
89
+ * retrieve `reference/functions/strategy.md` (for `strategy.entry`)
90
+
91
+ * **IF** user asks "Draw a box around the high and low of the last 10 bars":
92
+ * retrieve `reference/functions/drawing.md` (for `box.new`)
93
+ * retrieve `reference/functions/ta.md` (for `ta.highest`, `ta.lowest`)
94
+
95
+ * **IF** user asks "Why is my variable resetting every bar?":
96
+ * retrieve `concepts/execution_model.md` (check `var` usage)