Automatically generate TradingView Pine Script indicators from Schwab transaction CSV files to visualize your purchase lots across multiple stocks.
- Multi-Symbol Support: Single indicator works for all your stocks
- Purchase Lot Visualization: Blue gradient labels show lot sizes at purchase dates
- Average Cost Lines: Purple horizontal lines with text labels
- Summary Table: Overview of all symbols and their data
- Automatic Updates: Regenerate when you add new CSV files
-
Add your CSV files to the
data/directory- Files should be named like
AAP.csv,KSS.csv, etc. - Use Schwab's standard transaction export format
- Files should be named like
-
Generate the Pine Script:
python generate.py
-
Copy to TradingView:
- Copy
schwab-purchase-lots.pineto TradingView's Pine Editor - Add the indicator to a chart
- The indicator automatically shows data for the current symbol if there was an associated csv file for that symbol
- Copy
- Blue Labels: Purchase lots with gradient colors (darker = larger lots)
- Blue Lines: Average cost per share with text labels
- Summary Table: All symbols, lots, shares, and average costs
Schwab-Tv-Blotter/
├── data/ # Your CSV files go here
│ ├── AAP.csv
│ ├── KSS.csv
│ └── ...
├── output_pine.py # Main generator script
├── generate.py # Quick generation script
├── schwab-purchase-lots.pine # Generated Pine Script
└── README.md
Your Schwab CSV files should have these columns:
- Open Date: Purchase date (MM/DD/YYYY)
- Quantity: Number of shares
- Price: Purchase price per share
- Cost/Share: Cost basis per share
# Quick generation
python generate.py
# Custom options
python output_pine.py --data-dir data --output my_script.pine- Add new CSV files to
data/directory - Run
python generate.py - Copy the updated Pine Script to TradingView
Stock symbols in the following markets/exchanges
- NYSE
- NASDAQ
- AMEX
- ARCA
- Python 3.6+
- Schwab CSV export files
- TradingView account
- some tax lots don't get plotted for some reason, I ran into this issue when there were only 2 lots on a ticker. Um, this is fixed now? Keep an eye out for this just in case.
- Make label size proportional to the full position. The bucket approach has several limitations.
- Only works on daily timeframe, would be nice if this could aggregate dynamically per the timeframe
- I'm sure I'm forgetting other features that I was too impatient to resolve.
- No labels visible: Check that you're viewing the correct symbol chart
- CSV parsing errors: Ensure your CSV files match Schwab's export format
- Missing data: Verify CSV files are in the
data/directory
CRITICAL: Your Pine Script contains your actual purchase data!
The generated Pine Script files contain your real financial transaction data including:
- Purchase prices and quantities
- Purchase dates and cost basis
- Total investment amounts per symbol
- Portfolio composition and position sizes
- Publish Pine Scripts to GitHub - They contain your financial data
- Share Pine Scripts publicly on TradingView - Others can see your positions
- Post Pine Scripts on forums or social media - Your data becomes public
- Upload to public repositories - Even if you think it's "anonymized"
- Share screenshots showing your actual purchase lots and costs
- Keep Pine Scripts private - Only use them on your own TradingView account
- Use .gitignore - Prevents accidental commits of generated files
- Delete old Pine Scripts - Remove files you no longer need
- Check before sharing - Verify no financial data is included
- Use demo data - For public examples, use fake transaction data
- Regular cleanup: Delete old Pine Script files periodically
- Local only: Keep your CSV files and generated scripts on your local machine
- Backup safely: If backing up, use encrypted storage
- Monitor sharing: Be careful when sharing TradingView charts that show your indicators
If you want to share your work publicly, create a separate version with:
- Fake stock symbols (DEMO, TEST, etc.)
- Random purchase prices and quantities
- No real financial data
Remember: Your financial data is valuable and private. Protect it like you would protect your bank account information!
MIT License - feel free to modify and distribute.
