| name | pine-script-generator |
| description | Generate and update TradingView Pine Script code for visualizing options positions. Use when creating or modifying Pine scripts for options trading visualization. |
| allowed-tools | Read, Write, Edit, Bash(python:*), Grep, Glob |
Pine Script Generator
This skill generates TradingView Pine Script code to visualize options positions with color-coded lines showing strikes, expirations, and strategy types.
Instructions
When working with Pine scripts:
Understand the options data
- Parse portfolio CSV to extract options positions
- Identify option types (call/put)
- Determine position direction (long/short)
- Extract strikes and expiration dates
- Detect strategies (synthetic, spreads, etc.)
Generate Pine Script v5 code
- Use proper Pine Script v5 syntax
- Create horizontal lines for each strike price
- Color-code by option type and strategy:
- Long calls: Green
- Short calls: Red
- Long puts: Blue
- Short puts: Orange
- Synthetic positions: Purple
- Add labels with expiration dates
Include position details in labels
- Strike price
- Expiration date (formatted: YYYY-MM-DD)
- Quantity
- Option type and direction
Handle strategy detection
- Synthetic long: Long stock + Long put
- Synthetic short: Short stock + Short call
- Covered call: Long stock + Short call
- Protective put: Long stock + Long put
- Spreads: Multiple options same expiration
Pine Script Template Structure
//@version=5
indicator("Options Positions", overlay=true)
// Option position definitions
// Generated from portfolio CSV
// Long Calls (Green)
line.new(x1=bar_index[100], y1=STRIKE, x2=bar_index, y2=STRIKE,
color=color.green, width=2)
label.new(bar_index, STRIKE, "CALL EXP", color=color.green)
// Short Calls (Red)
line.new(x1=bar_index[100], y1=STRIKE, x2=bar_index, y2=STRIKE,
color=color.red, width=2)
label.new(bar_index, STRIKE, "CALL EXP", color=color.red)
// Long Puts (Blue)
line.new(x1=bar_index[100], y1=STRIKE, x2=bar_index, y2=STRIKE,
color=color.blue, width=2)
label.new(bar_index, STRIKE, "PUT EXP", color=color.blue)
// Short Puts (Orange)
line.new(x1=bar_index[100], y1=STRIKE, x2=bar_index, y2=STRIKE,
color=color.orange, width=2)
label.new(bar_index, STRIKE, "PUT EXP", color=color.orange)
Key Files
scripts/csv_to_options_tasty.py- Main Pine script generatorsrc/options_list.py- Options position analyzersrc/parse_utils.py- CSV parsing utilities
Common Tasks
Generate Pine Script from CSV
PYTHONPATH=src python scripts/csv_to_options_tasty.py
Update existing Pine Script
- Read current Pine script
- Parse new CSV data
- Generate new position lines
- Replace old position definitions
- Preserve script header and settings
Add new strategy visualization
- Detect the strategy in options data
- Choose appropriate color scheme
- Add line and label generation code
- Document the strategy in comments
Output Guidelines
When generating Pine scripts:
- Use Pine Script v5 syntax (
//@version=5) - Set
overlay=trueto display on price chart - Use clear, consistent color coding
- Include expiration dates in labels
- Group positions by strategy type in comments
- Keep code readable with proper spacing
Example Usage
When asked to "Generate a Pine script for my options positions":
- Locate the latest portfolio CSV in
data/ - Parse options positions using
options_list.py - Group by ticker (create separate scripts or use inputs)
- Generate line and label code for each position
- Color-code by type and strategy
- Output the complete Pine script
- Provide instructions for loading into TradingView
TradingView Integration
To use the generated script:
- Open TradingView chart for the ticker
- Click Pine Editor (bottom panel)
- Paste the generated script
- Click "Add to Chart"
- Positions will appear as colored lines with labels