Matching TradingView’s numbers¶
People moving from TradingView check one thing first: do the numbers match? Libraries often disagree on RSI, ATR and long EMAs, mostly in how the first values are started (seeded) and how much warm-up history there is. LumiBot’s built-ins follow the published Pine Script v6 formulas:
Indicator |
How LumiBot computes it (Pine v6 rule) |
|---|---|
|
Starts with the simple average of the first |
|
Gains and losses smoothed with Wilder’s average ( |
|
True range smoothed with |
|
Population standard deviation (divide by |
|
Not clamped to 0..100 (same as Pine). |
|
Restarts at each UTC day. |
The test suite checks every built-in against plain-loop reference implementations written from those formulas, on top of hand-worked values.
Why your numbers may still differ¶
Warm-up. EMA and RSI depend on every bar since the start. TradingView starts at the first bar it loaded; if you load fewer bars, early values differ. Load several times
lengthbars and compare recent values.Different data. Exchanges and data vendors disagree slightly on candles, especially volume. Compare against the same exchange.
Session vs UTC. LumiBot’s
vwapresets at UTC midnight. A stock chart that resets at the session open will differ.The live bar. TradingView redraws the live bar on every tick. Compare closed bars.
How to check a value yourself¶
On TradingView, add the indicator to a chart and note its value on a few closed bars (or export the chart data, where your plan allows it).
Load the same exchange’s candles into a DataFrame (for crypto, Stream an indicator live from a crypto exchange shows how).
Run
registry.create("rsi", length=14).compute(df)and compare the same bars.
Porting your own Pine script¶
Map each Pine piece to Python. All of these live in
lumibot.indicators.primitives and cost the same small time per bar:
Pine |
LumiBot |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
keys in |
Only port code you wrote yourself or have the right to use.