Video summary
5 Useful Libraries for TradingView
Main summary
Key takeaways
Overview
The video titled “5 Useful Libraries for TradingView” explains several open-source Pine Script libraries you can import into TradingView scripts to gain extra built-in functions. These libraries mainly improve coding “quality of life” and support more advanced analysis features.
Core idea: how to use TradingView libraries
- Use the Pine Script
importkeyword with a TradingView username to access libraries. - Autocomplete helps you find libraries published by that username.
- You can set an alias (example:
as zen) so functions are called like:zen.<function>().
1) The creator’s own Pine Script library (example library)
This library demonstrates typical library capabilities and organizes utilities into several categories.
Quality-of-life / coding helpers
- Quote price precision utilities
- Get/trim/convert decimal precision for the current symbol.
- Numeric conversion helpers for alerts/integration systems:
- Convert to whole numbers
- Convert pips ↔ whole numbers, points ↔ whole numbers
- Motivated by crypto symbols that sometimes have many decimals.
Market structure / analysis helpers
- Bars above a moving average
- Count how many bars have closed above a chosen MA over a lookback period.
- Candlestick detection functions
- Hammer, shooting star, engulfing candles, etc.
Backtesting filters
- Date/day filters to restrict strategy execution to specific time ranges.
- Enables walk-forward analysis / backtests within a chosen date window.
2) Official TradingView strategy library (Developer profile)
Key functions highlighted:
Position sizing
- Calculate position size by stop-loss percent or stop-loss ticks.
- Inputs include stop-loss value, risk percentage, and entry price.
- Notes on currency/accounting complexity:
- Should work well for stocks/CFDs
- Forex/crypto may be more complicated due to exchange-rate conversions.
Intraday trade management
- Close all at end of session (and a “sister” function with similar behavior).
- Closes positions on the close of the last bar in the trading session.
- Useful for day/intraday traders to avoid overnight gaps/weekend holds.
Performance stats over time
- Sharpe ratio and Sortino ratio
- Can reference the strategy’s Sharpe/Sortino values bar-by-bar, updating as the backtest progresses.
- This supports plotting/labeling these metrics as they evolve, rather than only viewing final results in the Strategy Tester.
3) TradingView ta library (technical analysis) — version mentioned as v7
Purpose
- Provides technical analysis functions not built into Pine by default (as claimed by the speaker).
Highlights
- CAGR (compound annual growth rate) between two points in time (useful for backtesting).
- All-time high/low helpers
- Computes all-time high/low from the first historical bar to the current bar (described as not looking forward).
- Contrasted with functions that might “look forward” on historical bars.
- Examples of advanced indicators:
- Double exponential moving average (DEMA) via
ema2style function usage. - Ichimoku
- Returns a tuple of Ichimoku components (speaker mentions a tuple /
TLnotion). - Emphasized because there may be no equivalent built-in
ta.ichimoku-style function otherwise.
- Returns a tuple of Ichimoku components (speaker mentions a tuple /
- Mentions many additional functions, with some unfamiliar to the speaker.
- Double exponential moving average (DEMA) via
4) PineCoders libraries (semi-official community)
PineCoders is described as a major Pine community whose contributions often become adopted or supported by TradingView developers.
Visible Chart library
- Provides functions that compute values based on only the visible bars currently shown on the chart.
- Example:
visible-prefixed functions (e.g., visible VWAP and visible volume-weighted values).
Tutorial/demonstration concept
- Modify a strategy to use a visible filter so buys only occur when the current bar is within the chart viewport.
- Strategy Tester behavior:
- With the visible-only filter enabled, the test executes only trades whose entry occurs within the visible chart range.
- The sell logic may still trigger after leaving the visible region (entry is constrained).
Use cases mentioned
- Walk-forward / time-window analysis
- Zoom to a period (e.g., mid-2006 to 2010) and evaluate results for that window.
- Example: checking performance during the 2008 financial crisis, showing it wasn’t affected much due to a long-term moving average “market regime” filter.
- Debugging
- Helps inspect what the script is doing within a specific chart section.
5) PineCoders time library
Purpose
- A quality-of-life utility library for converting and formatting timestamps into simple text strings.
Why it’s useful
- For displaying information to users (especially if publishing scripts publicly).
- For debugging and presenting time-related data cleanly.
Main speakers / sources
- Speaker: The YouTube presenter (TradingView/trader channel host; name not provided in subtitles).
- Library sources mentioned:
- Official TradingView Developer Profile (for the
strategylibrary) - TradingView
talibrary - PineCoders (Visible Chart and Time libraries)
- The speaker’s own library (used as the initial import example)
- Official TradingView Developer Profile (for the