ticker.inherit() - Pine Script Function
ticker.inherit()
Section titled “ticker.inherit()”Overview
Section titled “Overview”Constructs a ticker ID for the specified symbol with additional parameters inherited from the ticker ID passed into the function call, allowing the script to request a symbol’s data using the same modifiers that the from_tickerid has, including extended session, dividend adjustment, currency conversion, non-standard chart types, back-adjustment, settlement-as-close, etc.
Syntax
Section titled “Syntax”ticker.inherit(from_tickerid, symbol) → simple stringParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| from_tickerid | simple string | The ticker ID to inherit modifiers from. |
Remarks
Section titled “Remarks”- If the constructed ticker ID inherits a modifier that doesn’t apply to the symbol (e.g., if the from_tickerid has Extended Hours enabled, but no such option is available for the symbol), the script will ignore the modifier when requesting data using the ID.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("ticker.inherit")//@variable A "NASDAQ:AAPL" ticker ID with Extender Hours enabled.tickerExtHours = ticker.new("NASDAQ", "AAPL", session.extended)//@variable A Heikin Ashi ticker IDfor "NASDAQ:AAPL" with Extended Hours enabled.HAtickerExtHours =ticker.heikinashi(tickerExtHours)//@variable The "NASDAQ:MSFT" symbol with no modifiers.testSymbol = "NASDAQ:MSFT"//@variable A ticker IDfor "NASDAQ:MSFT" with inherited Heikin Ashi and Extended Hours modifiers.testSymbolHAtickerExtHours =ticker.inherit(HAtickerExtHours, testSymbol)//@variable The `close` price requested using "NASDAQ:MSFT" with inherited modifiers.secData = request.security(testSymbolHAtickerExtHours, "60", close, ignore_invalid_symbol = true)//@variable The `close` price requested using "NASDAQ:MSFT" without modifiers.compareData = request.security(testSymbol, "60", close, ignore_invalid_symbol = true)plot(secData, color = color.green)plot(compareData)