Library "composite_ticker_cleaner"
Extract a clean symbol from a composite ticker. E.g., (BINANCE:BTCUSD+KRAKEN:BTCUSD)/2 as input will return BTCUSD or BINANCE:BTCUSD
composite_ticker_cleaner_extract_first(symbol, keepexchange)
Extract the first symbol out of the supplied string (usually ticker.standard(syminfo.tickerid) )
Parameters:
symbol: string input string to search in
keepexchange: bool (optional) Keep exchange in the returned ticker? By default, we only return the symbol without the exchange.
Returns: first occurrence of a symbol
composite_ticker_cleaner_extract_first(keepexchange)
Extract the first symbol out of the current tickerid (as provided by ticker.standard(syminfo.tickerid) )
Parameters:
keepexchange: bool (optional) Keep exchange in the returned ticker? By default, we only return the symbol without the exchange.
Returns: first occurrence of a symbol in the current tickerid
This is inspired by the work I did on this indicator:
I needed a similar functionality in another script, so instead of duplicating code, I thought generalizing the process in a library could be helpful for me and others, and will be easier to maintain and upgrade with new features if I need to.
Extract a clean symbol from a composite ticker. E.g., (BINANCE:BTCUSD+KRAKEN:BTCUSD)/2 as input will return BTCUSD or BINANCE:BTCUSD
composite_ticker_cleaner_extract_first(symbol, keepexchange)
Extract the first symbol out of the supplied string (usually ticker.standard(syminfo.tickerid) )
Parameters:
symbol: string input string to search in
keepexchange: bool (optional) Keep exchange in the returned ticker? By default, we only return the symbol without the exchange.
Returns: first occurrence of a symbol
composite_ticker_cleaner_extract_first(keepexchange)
Extract the first symbol out of the current tickerid (as provided by ticker.standard(syminfo.tickerid) )
Parameters:
keepexchange: bool (optional) Keep exchange in the returned ticker? By default, we only return the symbol without the exchange.
Returns: first occurrence of a symbol in the current tickerid
This is inspired by the work I did on this indicator:
I needed a similar functionality in another script, so instead of duplicating code, I thought generalizing the process in a library could be helpful for me and others, and will be easier to maintain and upgrade with new features if I need to.
リリースノート:
Slight comment update
リリースノート:
v3
Updated:
* Now works for both series and simple string inputs (simple string is necessary to use with request.security, as initially intended!). We are using the new overloading functions feature in PineScript v5 to alllow this.
Updated:
* Now works for both series and simple string inputs (simple string is necessary to use with request.security, as initially intended!). We are using the new overloading functions feature in PineScript v5 to alllow this.
リリースノート:
v4
Update:
* Rename functions "composite_ticker_cleaner_extract_first" to "extract_first_symbol"
Update:
* Rename functions "composite_ticker_cleaner_extract_first" to "extract_first_symbol"
リリースノート:
v5
Added:
extract_before(symbol, pattern)
Extract the part of the string before the specified pattern
Parameters:
symbol: Input string to search in
pattern: Pattern to search
Returns: Part of the string before the first occurrence of the matched pattern
extract_before_usd(symbol)
Extract the part of the string before "USD" (includes USDT, USDC, etc). This is especially useful to extract the symbol out of USD* pair ticker. Eg, out of BTCUSD, we will extract BTC.
Parameters:
symbol: Input string to search in
Returns: Part of the string before the first occurrence of "USD".
display_table_text(intext, tooltip)
Display some text on the last bar. Helper function to facilitate debugging or user display (eg, to confirm which symbol was detected).
Parameters:
intext: Text to display.
tooltip: (optional) Tooltip text to display on mouse hover.
Returns: Nothing. Display the supplied text in a table in the top right corner. Note that this will not affect viewport scaling (ie, the viewport will still be scaled according to the content, not the text).
Added:
extract_before(symbol, pattern)
Extract the part of the string before the specified pattern
Parameters:
symbol: Input string to search in
pattern: Pattern to search
Returns: Part of the string before the first occurrence of the matched pattern
extract_before_usd(symbol)
Extract the part of the string before "USD" (includes USDT, USDC, etc). This is especially useful to extract the symbol out of USD* pair ticker. Eg, out of BTCUSD, we will extract BTC.
Parameters:
symbol: Input string to search in
Returns: Part of the string before the first occurrence of "USD".
display_table_text(intext, tooltip)
Display some text on the last bar. Helper function to facilitate debugging or user display (eg, to confirm which symbol was detected).
Parameters:
intext: Text to display.
tooltip: (optional) Tooltip text to display on mouse hover.
Returns: Nothing. Display the supplied text in a table in the top right corner. Note that this will not affect viewport scaling (ie, the viewport will still be scaled according to the content, not the text).