### Install Pinecone using Bash Source: https://github.com/claudianadalin/pinecone/blob/master/docs/getting-started.md This snippet demonstrates how to clone the Pinecone repository, set up a virtual environment, and install Pinecone in development mode. It requires Git and Python 3.10+. ```bash git clone https://github.com/claudianadalin/pinecone.git cd pinecone python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate pip install -e . ``` -------------------------------- ### Verify Pinecone Installation using Bash Source: https://github.com/claudianadalin/pinecone/blob/master/docs/getting-started.md This command verifies that Pinecone has been installed correctly by checking its version. It is a simple command-line interface check. ```bash pinecone --version ``` -------------------------------- ### Create PineScript Project Structure using Bash Source: https://github.com/claudianadalin/pinecone/blob/master/docs/getting-started.md These commands set up the basic directory structure for a new PineScript project, including the main project folder and subdirectories for source files. ```bash mkdir my-indicator cd my-indicator ``` -------------------------------- ### PineScript Example: Full Pipeline Input Files Source: https://github.com/claudianadalin/pinecone/blob/master/docs/how-it-works.md Provides the input PineScript files for a full pipeline example. Includes 'src/utils.pine' with an exported function and 'src/main.pine' which imports and uses the function. ```pinescript // src/utils.pine //@version=5 // @export double double(x) => x * 2 ``` ```pinescript // src/main.pine //@version=5 // @import { double } from "./utils.pine" indicator("Test") result = double(close) plot(result) ``` -------------------------------- ### Bundle and Copy PineScript Project using Bash Source: https://github.com/claudianadalin/pinecone/blob/master/docs/getting-started.md This command bundles the PineScript project and automatically copies the resulting bundled code to the system clipboard, facilitating quick pasting into TradingView's Pine Editor. ```bash pinecone build --copy ``` -------------------------------- ### PineScript Example: Full Pipeline Output Source: https://github.com/claudianadalin/pinecone/blob/master/docs/how-it-works.md Shows the final bundled PineScript output file generated by the 'pinecone build' process for the example input files. It includes the version annotation, indicator declaration, imported module code with renamed identifiers, and the main script code. ```pinescript //@version=5 indicator("Test") // --- Bundled modules --- // --- From: utils.pine --- __utils__double(x) => x * 2 // --- Main --- result = __utils__double(close) plot(result) ``` -------------------------------- ### Install Pinecone with Development Dependencies Source: https://github.com/claudianadalin/pinecone/blob/master/README.md Installs Pinecone and its development dependencies, including testing tools, using pip. ```bash git clone https://github.com/claudianadalin/pinecone.git cd pinecone python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate pip install -e . pip install -e ".[dev]" ``` -------------------------------- ### PineScript Main Indicator File Source: https://github.com/claudianadalin/pinecone/blob/master/docs/getting-started.md This PineScript code defines a TradingView indicator named 'My First Bundled Indicator'. It imports the `double` function from a utility module and plots the result of applying it to the closing price. ```pinescript //@version=5 // @import { double } from "./utils.pine" indicator("My First Bundled Indicator", overlay=true) result = double(close) plot(result, "Doubled Close", color=color.blue) ``` -------------------------------- ### Show Pinecone CLI Version Source: https://github.com/claudianadalin/pinecone/blob/master/docs/cli.md Displays the current version of the Pinecone CLI installed. ```bash pinecone --version ``` -------------------------------- ### PineScript Main Indicator Importing External Modules Source: https://github.com/claudianadalin/pinecone/blob/master/README.md An example of a main PineScript file (`main.pine`) that imports and uses functions (`double`, `triple`) from an external module (`utils.pine`). ```pinescript //@version=5 // @import { double, triple } from "./utils.pine" indicator("My Indicator", overlay=true) result = double(close) plot(result) ``` -------------------------------- ### PineScript Module with Exported Functions Source: https://github.com/claudianadalin/pinecone/blob/master/README.md An example PineScript module (`utils.pine`) that exports two functions: `double` and `triple`. These functions can be imported and used in other PineScript files. ```pinescript //@version=5 // @export double, triple double(x) => x * 2 triple(x) => x * 3 ``` -------------------------------- ### Pinecone Documentation Preview Locally Source: https://github.com/claudianadalin/pinecone/blob/master/README.md Commands to set up a virtual environment, serve the documentation locally using MkDocs, and then access it via a web browser. ```bash source .venv/bin/activate mkdocs serve ``` -------------------------------- ### Pinecone CLI Commands Source: https://github.com/claudianadalin/pinecone/blob/master/README.md Demonstrates various command-line interface commands for the Pinecone bundler, including basic build, custom configuration, watch mode, and clipboard integration. ```bash # Basic build pinecone build # Build with custom config path pinecone build --config path/to/pine.config.json # Watch mode - rebuild on file changes pinecone build --watch # Copy output to clipboard after build pinecone build --copy ``` -------------------------------- ### Pinecone Build Commands Source: https://context7.com/claudianadalin/pinecone/llms.txt Provides essential command-line interface (CLI) commands for building PineScript strategies using Pinecone. This includes a standard build command, a watch mode for continuous development, and an option to copy the built script directly to the clipboard for easy pasting into TradingView. ```bash # Build once pinecone build # Development mode with auto-rebuild pinecone build --watch # Build and copy to clipboard for TradingView pinecone build --copy ``` -------------------------------- ### Pinecone Project Configuration (pine.config.json) Source: https://context7.com/claudianadalin/pinecone/llms.txt Defines the entry point and output path for the Pinecone bundler. The `entry` field specifies the main PineScript file, and the `output` field determines where the bundled file will be saved. Supports nested directory structures for both entry and output paths. ```json { "entry": "src/main.pine", "output": "dist/bundle.pine" } { "entry": "src/indicators/main.pine", "output": "build/my-indicator.pine" } ``` -------------------------------- ### Build PineScript Project with CLI Source: https://context7.com/claudianadalin/pinecone/llms.txt Bundles PineScript files from multiple modules into a single output file using the Pinecone CLI. Supports specifying a custom configuration file path, copying the output to the clipboard, and enabling watch mode for automatic rebuilds on file changes. ```bash pinecone build pinecone build --config path/to/pine.config.json pinecone build --copy pinecone build --watch pinecone build --watch --copy ``` -------------------------------- ### Show Pinecone CLI Help Information Source: https://github.com/claudianadalin/pinecone/blob/master/docs/cli.md Displays comprehensive help information for the Pinecone CLI, including available commands and options. ```bash pinecone --help ``` -------------------------------- ### Pinecone Project Configuration Source: https://github.com/claudianadalin/pinecone/blob/master/README.md Configuration file for Pinecone projects, specifying the entry point and output file for the bundled script. ```json { "entry": "src/main.pine", "output": "dist/bundle.pine" } ``` -------------------------------- ### pinecone --help Source: https://github.com/claudianadalin/pinecone/blob/master/docs/cli.md Shows general help information for the Pinecone CLI. ```APIDOC ## pinecone --help ### Description Show help information for the Pinecone CLI. ### Method CLI COMMAND ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None #### Options - `--help` (boolean) - Show help message. ### Request Example ```bash pinecone --help ``` ### Response #### Success Response (0) Displays comprehensive help information for the Pinecone CLI and its commands. #### Response Example N/A ``` -------------------------------- ### PineScript Configuration Options (JSON) Source: https://github.com/claudianadalin/pinecone/blob/master/docs/configuration.md Illustrates the essential configuration options for `pine.config.json`. It shows the required `entry` field for the main PineScript file and the `output` field for the bundled file. Paths are relative to the config file. ```json { "entry": "src/main.pine" } ``` ```json { "output": "dist/bundle.pine" } ``` ```json { "entry": "src/main.pine", "output": "dist/bundle.pine" } ``` -------------------------------- ### Pinecone Build Pipeline Visualization Source: https://github.com/claudianadalin/pinecone/blob/master/docs/how-it-works.md A visual representation of the Pinecone bundling pipeline, showing the sequential steps involved in transforming source files into a single output file. Each step highlights a key operation within the build process. ```text ┌─────────────────┐ │ 1. Parse │ Read entry file and discover imports └────────┬────────┘ │ ┌────────▼────────┐ │ 2. Resolve │ Build dependency graph, detect cycles └────────┬────────┘ │ ┌────────▼────────┐ │ 3. Rename │ Prefix all identifiers to avoid collisions └────────┬────────┘ │ ┌────────▼────────┐ │ 4. Merge │ Combine modules in dependency order └────────┬────────┘ │ ┌────────▼────────┐ │ 5. Output │ Write single TradingView-compatible file └─────────────────┘ ``` -------------------------------- ### Specify Configuration File Path (Bash) Source: https://github.com/claudianadalin/pinecone/blob/master/docs/configuration.md Demonstrates how to use the `--config` flag in the Pinecone CLI to specify a custom path for the `pine.config.json` file. This allows for greater flexibility in project organization. ```bash pinecone build --config path/to/pine.config.json ``` -------------------------------- ### Import Functions in PineScript Source: https://github.com/claudianadalin/pinecone/blob/master/docs/configuration.md Demonstrates how to import functions from other PineScript files using the `// @import` directive. Specifies the functions to import and the relative path to the source file, including the `.pine` extension. ```pinescript // @import { functionName } from "./path/to/file.pine" ``` ```pinescript // @import { foo, bar, baz } from "./utils.pine" ``` -------------------------------- ### Build PineScript Project with Pinecone CLI Source: https://github.com/claudianadalin/pinecone/blob/master/docs/cli.md Bundles PineScript files into a single output. Supports custom configuration paths, watch mode for automatic rebuilding, copying output to clipboard, and combining options. ```bash pinecone build ``` ```bash pinecone build --config ./configs/production.json ``` ```bash pinecone build --watch ``` ```bash pinecone build --copy ``` ```bash pinecone build --watch --copy ``` -------------------------------- ### pinecone build Source: https://github.com/claudianadalin/pinecone/blob/master/docs/cli.md Bundles your PineScript files into a single output. Supports watching for changes, copying output to the clipboard, and using a custom configuration file. ```APIDOC ## pinecone build ### Description Bundle your PineScript files into a single output. ### Method CLI COMMAND ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None #### Options - `--config PATH` or `-c` (string) - Optional - Path to pine.config.json (default: ./pine.config.json) - `--watch` or `-w` (boolean) - Optional - Watch for file changes and rebuild automatically - `--copy` (boolean) - Optional - Copy output to clipboard after build - `--help` (boolean) - Optional - Show help message ### Request Example ```bash pinecone build pinecone build --config ./configs/production.json pinecone build --watch pinecone build --copy pinecone build --watch --copy ``` ### Response #### Success Response (0) Build successful. Output is generated and optionally copied to clipboard. #### Response Example N/A ``` -------------------------------- ### Bundle PineScript Project with Python API Source: https://context7.com/claudianadalin/pinecone/llms.txt Bundles PineScript files into a single output by resolving dependencies and merging modules using the Pinecone Python API. It takes a `PineconeConfig` object, executes the bundling process, and writes the result to the specified output file. Includes error handling for the bundling process. ```python from pathlib import Path from pinecone.config import PineconeConfig from pinecone.bundler import bundle, write_bundle # Create configuration config = PineconeConfig( entry=Path("/project/src/main.pine"), output=Path("/project/dist/bundle.pine"), root_dir=Path("/project") ) try: # Bundle the project result = bundle(config) # Write to file write_bundle(result) print(f"✓ Bundled {result.modules_count} modules") print(f" Entry: {result.entry_path}") print(f" Output: {result.output_path}") print(f" Size: {len(result.output)} bytes") except Exception as e: print(f"Error: {e}") ``` -------------------------------- ### Watch and Rebuild Project Files with Python Source: https://context7.com/claudianadalin/pinecone/llms.txt Automatically rebuilds project files when changes are detected using Python's pathlib and Pinecone's watcher module. It takes a Pinecone configuration, and provides callbacks for success and error handling. Debouncing is supported to limit rebuild frequency. ```python from pathlib import Path from pinecone.config import load_config from pinecone.bundler import bundle, write_bundle, BundleResult from pinecone.watcher import watch_and_rebuild from pinecone.errors import PineconeError def on_success(result: BundleResult) -> None: print(f"✓ Rebuilt: {result.modules_count} modules → {result.output_path}") def on_error(error: Exception) -> None: if isinstance(error, PineconeError): print(f"✗ Build failed: {error}") else: print(f"✗ Unexpected error: {error}") try: config = load_config() # Initial build result = bundle(config) write_bundle(result) on_success(result) # Watch for changes (blocks until Ctrl+C) print("Watching for changes...") watch_and_rebuild( config=config, on_success=on_success, on_error=on_error, debounce_seconds=0.1 ) except KeyboardInterrupt: print("Stopped watching") except PineconeError as e: print(f"Error: {e}") ``` -------------------------------- ### Bash Command for Pinecone Build Source: https://github.com/claudianadalin/pinecone/blob/master/docs/index.md Executes the Pinecone build command to bundle PineScript files. This command is run from the terminal to process the source files and generate a single, TradingView-compatible output script. ```bash pinecone build ``` -------------------------------- ### Run Pinecone Tests Source: https://github.com/claudianadalin/pinecone/blob/master/README.md Commands to run the project's tests using pytest, including an option to generate a test coverage report. ```bash # Run tests pytest # Run tests with coverage pytest --cov ``` -------------------------------- ### Pinecone CLI Error Message: Entry File Not Found Source: https://github.com/claudianadalin/pinecone/blob/master/docs/cli.md Indicates that the specified entry file in the configuration is missing. Verify the `entry` path in `pine.config.json`. ```bash Error: Entry file not found: src/main.pine ``` -------------------------------- ### Load Pinecone Configuration with Python API Source: https://context7.com/claudianadalin/pinecone/llms.txt Loads and validates a `pine.config.json` file using the Pinecone Python API, with automatic path resolution for the configuration file. It can load the default configuration from the current directory or from a specified file path. Includes error handling for configuration loading issues. ```python from pathlib import Path from pinecone.config import load_config from pinecone.errors import ConfigError try: # Load from current directory config = load_config() # Or load from specific path config = load_config(Path("/path/to/pine.config.json")) print(f"Entry: {config.entry}") print(f"Output: {config.output}") print(f"Root: {config.root_dir}") print(f"Source dir: {config.src_dir}") except ConfigError as e: print(f"Configuration error: {e}") ``` -------------------------------- ### Pinecone Exception Handling in Python Source: https://context7.com/claudianadalin/pinecone/llms.txt Demonstrates how to handle various Pinecone-specific exceptions in Python when using the Pinecone bundler. It covers configuration errors, parsing errors, module not found errors, export not found errors, and circular dependency errors. This helps in debugging and providing informative error messages to the user. ```python from pinecone.errors import ( PineconeError, ConfigError, ParseError, ModuleNotFoundError, ExportNotFoundError, CircularDependencyError ) from pinecone.config import load_config from pinecone.bundler import bundle try: config = load_config() result = bundle(config) except ConfigError as e: # Missing or invalid pine.config.json print(f"Config error: {e}") # Example: Config error in pine.config.json: Missing required fields: entry except ParseError as e: # Invalid PineScript syntax print(f"Parse error at {e.path}:{e.line}: {e.message}") except ModuleNotFoundError as e: # Import references non-existent file print(f"Module not found: {e}") print(f"Available files: {e.available}") except ExportNotFoundError as e: # Import references name not exported print(f"Export not found: {e}") print(f"Available exports: {e.available_exports}") except CircularDependencyError as e: # Circular import detected print(f"Circular dependency: {e}") print(f"Cycle: {' → '.join(p.name for p in e.cycle)}") except PineconeError as e: # Catch-all for other errors print(f"Bundler error: {e}") ``` -------------------------------- ### Export Functions in PineScript Source: https://github.com/claudianadalin/pinecone/blob/master/docs/configuration.md Shows how to export functions from a PineScript file for use in other parts of the project. Uses the `// @export` directive followed by the function name or a comma-separated list. ```pinescript // @version=5 // @export functionName functionName(x) => x * 2 ``` ```pinescript // @export foo, bar, baz ``` -------------------------------- ### Parse PineScript Module to AST with Python Source: https://context7.com/claudianadalin/pinecone/llms.txt Parses a single PineScript file into a module object containing its Abstract Syntax Tree (AST), exported names, and imported modules. This function is useful for analyzing and manipulating PineScript code programmatically. It raises a ParseError on failure. ```python from pathlib import Path from pinecone.resolver import parse_module from pinecone.errors import ParseError try: module_path = Path("src/utils.pine") module = parse_module(module_path) print(f"Module: {module.path}") print(f"Exports: {module.exported_names}") for imp in module.imports: print(f"Import from {imp.from_path}: {imp.names}") # Access AST for custom processing print(f"AST body statements: {len(module.ast.body)}") except ParseError as e: print(f"Parse error: {e}") ``` -------------------------------- ### pinecone --version Source: https://github.com/claudianadalin/pinecone/blob/master/docs/cli.md Displays the current version of the Pinecone CLI. ```APIDOC ## pinecone --version ### Description Show the current version of Pinecone. ### Method CLI COMMAND ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None #### Options - `--version` (boolean) - Display the version of Pinecone. ### Request Example ```bash pinecone --version ``` ### Response #### Success Response (0) Displays the installed Pinecone version. #### Response Example ``` Pinecone CLI v1.2.3 ``` ``` -------------------------------- ### PineScript Generic Type Syntax Fix Source: https://github.com/claudianadalin/pinecone/blob/master/docs/how-it-works.md Illustrates a common bug in the pynescript library related to generic type syntax and how Pinecone corrects it. It shows the malformed syntax before the fix and the correct syntax after. ```pinescript // Before (broken) array.new < line > 500 ``` ```pinescript // After (fixed) array.new(500) ``` -------------------------------- ### Pinecone CLI Error Message: Config File Not Found Source: https://github.com/claudianadalin/pinecone/blob/master/docs/cli.md Indicates that the `pine.config.json` file was not found. Requires creating the file or specifying its path using the `--config` option. ```bash Error: Config file not found. Create a pine.config.json file with 'entry' and 'output' fields. ``` -------------------------------- ### PineScript Main Indicator with Import Source: https://github.com/claudianadalin/pinecone/blob/master/docs/index.md Defines a TradingView indicator named 'My Indicator'. It imports the 'double' function from the 'utils.pine' module using the '@import' directive. The imported function is then used to calculate and plot a result based on the closing price. ```pinescript // @version=5 // @import { double } from "./utils.pine" indicator("My Indicator", overlay=true) result = double(close) plot(result) ``` -------------------------------- ### PineScript Utility Functions Source: https://context7.com/claudianadalin/pinecone/llms.txt Provides utility functions for PineScript, including 'normalize' to scale a value within a range and 'clamp' to restrict a value within a given minimum and maximum. These functions are exported for use in other PineScript files. ```pinescript // @version=5 // @export normalize, clamp normalize(value, min, max) => (value - min) / (max - min) clamp(value, min, max) => math.max(min, math.min(max, value)) ``` -------------------------------- ### Pinecone CLI Error Message: Module Not Found Source: https://github.com/claudianadalin/pinecone/blob/master/docs/cli.md Indicates that an imported module file could not be located. Ensure the import path is correct and the file exists. ```bash Error: Module not found: ./utils.pine ``` -------------------------------- ### Resolve Dependencies and Detect Cycles with Python Source: https://context7.com/claudianadalin/pinecone/llms.txt Builds a complete dependency graph for PineScript files, providing a topological ordering and detecting circular dependencies. This is essential for managing complex projects with interdependencies. It can raise ModuleNotFoundError, ExportNotFoundError, or CircularDependencyError. ```python from pathlib import Path from pinecone.resolver import resolve_dependencies from pinecone.errors import ( ModuleNotFoundError, ExportNotFoundError, CircularDependencyError ) try: entry_path = Path("src/main.pine") root_dir = Path("/project") # Resolve all dependencies graph = resolve_dependencies(entry_path, root_dir) print(f"Entry module: {graph.entry.path}") print(f"Total modules: {len(graph.modules)}") print("\nDependency order:") for path in graph.order: module = graph.modules[path] deps = [imp.from_path for imp in module.imports] print(f" {path.name} → {deps}") except CircularDependencyError as e: print(f"Circular dependency: {e}") except ModuleNotFoundError as e: print(f"Module not found: {e}") except ExportNotFoundError as e: print(f"Export not found: {e}") ``` -------------------------------- ### PineScript Main Trading Strategy Source: https://context7.com/claudianadalin/pinecone/llms.txt Defines a main trading strategy that imports and utilizes moving average and RSI indicators. It includes logic for entering long positions on a fast MA crossover with the slow MA when RSI is oversold, and entering short positions on a crossunder when RSI is overbought. It also plots the moving averages. ```pinescript // @version=5 // @import { fastMA, slowMA } from "./indicators/moving-averages.pine" // @import { calculateRSI, isOverbought, isOversold } from "./indicators/rsi.pine" strategy("My Strategy", overlay=true) // Calculate indicators fast = fastMA(close) slow = slowMA(close) rsi = calculateRSI(close, 14) // Trading logic longCondition = ta.crossover(fast, slow) and isOversold(rsi) shortCondition = ta.crossunder(fast, slow) and isOverbought(rsi) if longCondition strategy.entry("Long", strategy.long) if shortCondition strategy.entry("Short", strategy.short) // Plot indicators plot(fast, "Fast MA", color=color.blue) plot(slow, "Slow MA", color=color.red) ``` -------------------------------- ### Importing Exports in PineScript Source: https://context7.com/claudianadalin/pinecone/llms.txt Imports specific exported functions and variables from other PineScript modules using the `@import` comment directive with destructuring syntax. Paths are relative, and all imported names must be explicitly exported in the source module. Import statements are removed in the final bundle. ```pinescript //@version=5 // @import { calculateMA, calculateEMA, PERIOD } from "./utils/moving-averages.pine" indicator("My Indicator", overlay=true) ma = calculateMA(close, PERIOD) tema = calculateEMA(close, PERIOD) plot(ma, "MA", color=color.blue) plot(ema, "EMA", color=color.red) ``` -------------------------------- ### Bundled PineScript Output Source: https://github.com/claudianadalin/pinecone/blob/master/docs/index.md The final bundled PineScript code after processing by Pinecone. It includes the main indicator definition and the bundled utility functions, prefixed with their module names to prevent collisions. The original imports are replaced with the inlined code. ```pinescript // @version=5 indicator("My Indicator", overlay=true) // --- Bundled modules --- // --- From: utils.pine --- __utils__double(x) => x * 2 // --- Main --- result = __utils__double(close) plot(result) ``` -------------------------------- ### Parse Exports and Imports from PineScript Source with Python Source: https://context7.com/claudianadalin/pinecone/llms.txt Parses @export and @import directives directly from PineScript source code strings. It can extract individual directives with their line numbers and names, or provide flat lists of all exported and imported names. This is useful for static analysis of script dependencies and visibility. ```python from pinecone.directives import ( parse_exports, parse_imports, get_all_exported_names, get_all_imported_names ) source = ''' //@version=5 // @export foo, bar, baz // @import { utilA, utilB } from "./utils.pine" // @import { helper } from "../helpers/helper.pine" foo() => 1 bar() => 2 baz() => 3 ''' # Parse exports exports = parse_exports(source) for exp in exports: print(f"Line {exp.line_number}: exports {exp.names}") # Output: Line 2: exports ['foo', 'bar', 'baz'] # Parse imports imports = parse_imports(source) for imp in imports: print(f"Line {imp.line_number}: import {imp.names} from {imp.from_path}") # Output: Line 3: import ['utilA', 'utilB'] from ./utils.pine # Line 4: import ['helper'] from ../helpers/helper.pine # Get flat lists exported = get_all_exported_names(source) imported = get_all_imported_names(source) print(f"All exports: {exported}") print(f"All imports: {imported}") ``` -------------------------------- ### PineScript RSI Indicator with Utilities Source: https://context7.com/claudianadalin/pinecone/llms.txt Implements the Relative Strength Index (RSI) calculation, incorporating the 'clamp' utility function to keep the RSI value between 0 and 100. It also provides helper functions 'isOverbought' and 'isOversold' to check standard RSI thresholds. ```pinescript // @version=5 // @export calculateRSI, isOverbought, isOversold // @import { clamp } from "../utils/math.pine" calculateRSI(source, length) => clamp(ta.rsi(source, length), 0, 100) isOverbought(rsi) => rsi > 70 isOversold(rsi) => rsi < 30 ``` -------------------------------- ### PineScript Moving Average Indicators Source: https://context7.com/claudianadalin/pinecone/llms.txt Defines two moving average indicator functions, 'fastMA' and 'slowMA', which calculate the Simple Moving Average (SMA) for a given source with different lengths (10 and 30 respectively). These functions are exported for reuse. ```pinescript // @version=5 // @export fastMA, slowMA fastMA(source) => ta.sma(source, 10) slowMA(source) => ta.sma(source, 30) ``` -------------------------------- ### Pinecone CLI Error Message: Export Not Found Source: https://github.com/claudianadalin/pinecone/blob/master/docs/cli.md Indicates that a requested export from a module is not available. Add `// @export ` to the target file to make it exportable. ```bash Error: Name 'foo' is not exported from ./utils.pine ``` -------------------------------- ### Exporting Variables and Functions in PineScript Source: https://context7.com/claudianadalin/pinecone/llms.txt Marks functions and variables for export from a PineScript module using the `@export` comment directive. Only exported items are accessible from other modules via the `@import` directive. Private functions or variables not marked for export remain local to the module. ```pinescript //@version=5 // @export calculateMA, calculateEMA, PERIOD PERIOD = 20 calculateMA(source, length) => ta.sma(source, length) calculateEMA(source, length) => ta.ema(source, length) // This function is NOT exported and remains private internalHelper() => // private implementation 42 ``` -------------------------------- ### PineScript Identifier Renaming Before and After Source: https://github.com/claudianadalin/pinecone/blob/master/docs/how-it-works.md Demonstrates how Pinecone renames top-level identifiers within dependency modules to prevent naming collisions. Identifiers like functions and variables are prefixed based on their file path. ```pinescript // utils/math.pine double(x) => x * 2 result = 0 ``` ```pinescript // utils/math.pine (after renaming) __utils_math__double(x) => x * 2 __utils_math__result = 0 ``` -------------------------------- ### Rename Identifiers in AST with Python Source: https://context7.com/claudianadalin/pinecone/llms.txt Renames identifiers within a PineScript Abstract Syntax Tree (AST) to prevent namespace collisions. This involves parsing the module, extracting top-level identifiers, building a rename map with namespace prefixes, and applying the renaming using an IdentifierRenamer. The renamed AST can then be unparsed back into code. ```python from pathlib import Path from pinecone.resolver import parse_module from pinecone.renamer import ( IdentifierRenamer, extract_top_level_identifiers, build_rename_map, path_to_prefix ) from pynescript.ast import unparse # Parse a module module = parse_module(Path("src/utils.pine")) # Extract identifiers to rename identifiers = extract_top_level_identifiers(module.ast) print(f"Identifiers: {identifiers}") # Output: ['myFunc', 'myVar', 'CONSTANT'] # Build rename map with namespace prefix renames = build_rename_map( identifiers, module_path=Path("src/utils.pine"), root_dir=Path(".") ) print(f"Rename map: {renames}") # Output: {'myFunc': '__utils__myFunc', 'myVar': '__utils__myVar', ...} # Apply renaming to AST renamer = IdentifierRenamer(renames) renamer.visit(module.ast) # Generate renamed code output = unparse(module.ast) print(output) ``` -------------------------------- ### Pinecone CLI Error Message: Circular Dependency Source: https://github.com/claudianadalin/pinecone/blob/master/docs/cli.md Indicates a circular dependency between PineScript files. Refactor the code to break the circular import chain. ```bash Error: Circular dependency detected: a.pine → b.pine → a.pine ``` -------------------------------- ### PineScript Utility Function Export Source: https://github.com/claudianadalin/pinecone/blob/master/docs/index.md Defines a reusable utility function 'double' that multiplies its input by two. This function is intended to be exported for use in other PineScript modules. It uses the '@export' directive for visibility. ```pinescript // @version=5 // @export double double(x) => x * 2 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.