Functions
talib.correlation()
Correlation coefficient. Describes the degree to which two series tend to deviate from their ta.sma values.
Syntax
talib.correlation(series float source1, series float source2, series int length) → series float
Arguments
source1 required series float Source series. source2 required series float Target series. length required series int Length (number of bars back). Return Type
series float Example
indicator("Price-Volume Correlation", overlay=false)
// Input for correlation period
length = input(20, title="Correlation Length")
// Calculate correlation between closing price and volume
correlationValue = ta.correlation(close, volume, length)
// Plot correlation value
plot(correlationValue, title="Price-Volume Correlation", color=color.blue, linewidth=2)
// Add reference levels
hline(1, "Perfect Positive", color=color.green)
hline(0, "No Correlation", color=color.gray)
hline(-1, "Perfect Negative", color=color.red)