使用Pandas实现Chaikin Oscillator:自研结果与TradingView不符
Custom Chaikin Oscillator Doesn't Match TradingView Results
I’m stuck trying to build the Chaikin Oscillator from scratch—my code’s output just doesn’t line up with what TradingView’s API returns. I’ve gone over the formula multiple times but can’t spot the issue, so I’m hoping someone here can help me debug this.
Background
- Dataset Structure: My data has these columns:
index,Timestamp,Open,Close,High,Low,Volume,Chaikin - My Output: Here’s how my generated Chaikin Oscillator compares to the asset’s closing price:

- TradingView Reference: This is the expected output from TradingView for the same asset/timeframe:

My Code Implementation
import pandas as pd def compute_chaikin_oscillator(data): # Calculate Money Flow Multiplier data['MF_Multiplier'] = ((data['Close'] - data['Low']) - (data['High'] - data['Close'])) / (data['High'] - data['Low']) # Handle division by zero when High == Low data['MF_Multiplier'] = data['MF_Multiplier'].fillna(0) # Money Flow Volume data['MF_Volume'] = data['MF_Multiplier'] * data['Volume'] # Accumulation/Distribution Line (ADL) data['ADL'] = data['MF_Volume'].cumsum() # EMA calculations (3-period and 10-period) data['EMA_3'] = data['ADL'].ewm(span=3, adjust=False, min_periods=3).mean() data['EMA_10'] = data['ADL'].ewm(span=10, adjust=False, min_periods=10).mean() # Chaikin Oscillator = EMA(3) - EMA(10) data['Chaikin'] = data['EMA_3'] - data['EMA_10'] return data # Load and process data df = pd.read_csv('historical_data.csv') df = compute_chaikin_oscillator(df)
What I’ve Already Checked
- Confirmed the Money Flow Multiplier formula matches the standard Chaikin definition
- Verified the ADL is correctly calculated as a cumulative sum of the Money Flow Volume
- Tested both
adjust=Trueandadjust=Falsefor the EWM function - Confirmed I’m using the standard 3-period and 10-period EMA windows
Even after all that, my Chaikin values are inconsistent with TradingView’s output. Does anyone see a mistake here, or know about subtle differences in how TradingView calculates this indicator?
内容的提问来源于stack exchange,提问作者Jarro




