# PineScript Guide: QuanTAlib Indicators for TradingView
> "You do not need to understand the math. But the math does not care whether you understand it."
## Welcome, Brave Copy-Paster
You are here because you want an indicator on your TradingView chart. Maybe someone on Crypto Twitter posted a screenshot with colored lines and you thought "I need that." Maybe you googled "best RSI Pine Script" at 2 AM. Maybe you clicked a link by accident. All valid paths to enlightenment.
Here is the good news: QuanTAlib provides **Pine Script v6 source code** for every one of its 393 indicators. Each script is self-contained, tested against the C# reference implementation, and ready to paste into TradingView's Pine Editor. No dependencies. No imports. No subscription to someone's Discord.
Here is the less-good news: the scripts contain actual mathematics. You do not have to read it. But it is there, silently judging.
## How to Use a Pine Script (The Short Version)
1. Find the indicator you want (see table below)
2. Click the link to open the `.pine` file
3. Copy the entire file contents
4. Open TradingView. Click "Pine Editor" at the bottom
5. Delete whatever is in there. Paste the code
6. Click "Add to chart"
7. Adjust the inputs in the indicator settings panel
That is it. You have deployed a mathematically rigorous indicator without writing a single line of code. Your ancestors would be proud.
## Finding Your Indicator
Every indicator has a `.pine` file sitting next to its C# implementation and documentation. The folder structure is predictable:
``` shell
lib/
trends_IIR/
ema/
Ema.cs ← the actual engine (C#, you can ignore this)
FIR stands for Finite Impulse Response. It means the average uses a fixed window of bars. SMA is an FIR filter. You have been using FIR filters this whole time.
| Indicator | What It Does | Pine Script |
| :--- | :--- | :--- |
| SMA | Simple Moving Average (the one everyone knows) | [sma.pine](../lib/trends_FIR/sma/sma.pine) |
| WMA | Weighted Moving Average | [wma.pine](../lib/trends_FIR/wma/wma.pine) |
| BWMA | Butterworth-Weighted MA | [bwma.pine](../lib/trends_FIR/bwma/bwma.pine) |
| CRMA | Crowley MA | [crma.pine](../lib/trends_FIR/crma/crma.pine) |
| SP15 | SP-15 MA | [sp15.pine](../lib/trends_FIR/sp15/sp15.pine) |
| TUKEY_W | Tukey-Windowed MA | [tukey_w.pine](../lib/trends_FIR/tukey_w/tukey_w.pine) |
| RAIN | RAIN MA | [rain.pine](../lib/trends_FIR/rain/rain.pine) |
#### Moving Averages: IIR (the "smart" ones)
IIR stands for Infinite Impulse Response. These use recursive feedback: the previous output affects the current output. Generally smoother, lower lag, and harder to understand. The indicator descriptions link to documentation if curiosity ever strikes.
| Indicator | What It Does | Pine Script |
| :--- | :--- | :--- |
| EMA | Exponential MA (the popular one) | [ema.pine](../lib/trends_IIR/ema/ema.pine) |
| DEMA | Double EMA (less lag) | [dema.pine](../lib/trends_IIR/dema/dema.pine) |
| TEMA | Triple EMA (even less lag) | [tema.pine](../lib/trends_IIR/tema/tema.pine) |
| T3 | Tillson T3 (six-stage cascade) | [t3.pine](../lib/trends_IIR/t3/t3.pine) |
These are the heavy artillery. Kalman filters, Butterworth filters, wavelets. If you do not know what a transfer function is, start with the moving averages above and come back when you are ready. No judgment. (Some judgment.)
**Not every indicator is listed here.** Browse the [full catalog of 393 indicators](../lib/_index.md) for the complete collection, including cycles, statistics, error metrics, reversals, numerics, and forecasts.
## Anatomy of a QuanTAlib Pine Script
Every script follows the same structure. Understanding this structure is optional but occasionally useful when things do not look right on your chart.
- **Inputs section**: Change `10` to whatever period you want as the default. Or just use the TradingView settings panel after adding the indicator.
- **Plot section**: Change `color.yellow` to whatever color you prefer. Options include `color.red`, `color.green`, `color.blue`, `color.white`, `color.orange`, `color.purple`.
- **The function**: Do not touch this unless you know what you are doing. It was validated against the C# reference implementation. Your modifications will not be validated against anything.
## Common Questions
### "The indicator shows values from bar 1 — shouldn't there be a warmup gap?"
That is correct behavior. QuanTAlib generates output from the very first bar. A 14-period RSI with only 5 bars uses the best estimate possible given available data. The values become fully converged once enough bars have accumulated, but you never see NaN or blank bars. Other libraries leave gaps. QuanTAlib fills them with mathematically defensible approximations that improve as data accumulates.
### "Can I use this in a strategy?"
Yes. Replace `indicator(...)` with `strategy(...)` and add your entry/exit logic. The indicator function itself does not change.
### "The values differ from TradingView's built-in version"
Possible reasons, in order of likelihood:
1. **Different default parameters.** Check the period, source, and any multipliers.
2. **Different warmup handling.** QuanTAlib uses exponential compensation from bar 1. TradingView's built-in indicators sometimes use different warmup methods.
3. **You are looking at the wrong indicator.** DEMA is not "double EMA period." It is a specific algorithm by Patrick Mulloy.
### "I modified the math and now it is broken"
Put the original code back. The math was correct before you edited it.
### "Which moving average should I use?"
If you are asking this question, use EMA. It is the Honda Civic of moving averages: reliable, understood by everyone, and good enough for most situations. Come back and explore JMA, KAMA, or T3 when you have a specific problem that EMA does not solve.
### "Can I combine multiple indicators?"
Yes. Add multiple scripts to your chart or combine functions within a single script:
// Or use QuanTAlib versions by pasting the function definitions
// from their respective .pine files and calling them
plot(rsi_val, "RSI", color=color.purple)
hline(70, "Overbought", color=color.red)
hline(30, "Oversold", color=color.green)
```
## Going Deeper (If You Dare)
Each indicator has a `.md` documentation file next to its `.pine` file. These contain:
- Mathematical formulas (yes, with actual math notation)
- Historical context (who invented it and why)
- Performance characteristics
- Validation against other libraries
- Common pitfalls
For example: [EMA documentation](../lib/trends_IIR/ema/Ema.md) explains the exponential warmup compensator, why it matters, and why most other implementations get the first few values wrong.
You do not have to read any of this. But if you ever wonder why your backtest results differ from someone else's, the answer is probably in there.
## The Full Catalog
**[All 393 indicators with descriptions →](../lib/_index.md)**
Every indicator in that list has a `.pine` file. Every `.pine` file works on TradingView. Every implementation matches the C# reference engine.