Open nl8-gh opened 1 year ago
maybe something like this?
script variables:
sources
- for all
sources.perp
- for all sources with perp type
sources.futures
- for all sources with futures type
sources.spot
- for all sources with spot type
sources.exchange.BINANCE
- for all sources from BINANCE exchange
sources.filter(source => source.exchange === 'BINANCE' && source.type === 'PERP')
- maybe for customization
or just have a filter tab where you can select which sources similar to how the sources search works
Thats a great starter! I even didn't think about how to actually implement it.
Following is a brain dump of my wet dreams. Please expand the below & sorry for the text wall.
maybe something like this?
script variables:
Not like this because someone might want to filter on multiple exchange, or combine multiple filters (type + exchange)
What you want is a source()
function
taking parameter likesource({ type: 'perp', quote: 'USDT' })
source({ type: 'spot', exchange: 'BITFINEX' })
From there, in the script transpilation parse these function calls and store the filters somewhere then we are going to need a second step to the transpilation dedicated to transpile these calls into actual markets data path (bars.renderer.sources[...]) so that the script is not retranspiled in it's entierty each time we change the pane's sources
by default should result in the average of the ohlc based on the given filters but in a more advanced version of that implementation we could imagine a second parameter mathing one of the source field (close, high, vbuy etc) to aggregate into
spotcvd = source({type: 'spot'}, 'vbuy') - source({type: 'spot'}, 'vsell')
How useful would that be 😄
draw close of spot markets available on the pane
line(source(close, type='spot'))
draw candlestick of spot markets available
candlestick(avg_ohlc(source(type='spot')))
cvd per type
line(
cum(source(vbuy, type=spot) - source(vsell, type=spot)),
title=spot cvd,
color=limegreen
)
line(
cum(source(vbuy, type=perp) - source(vsell, type=perp)),
title=perp cvd,
color=slateblue
)
draw heikinashi of BITFINEX spot markets only
candlestick(avg_heikinashi(source(exchange=BITFINEX, type=spot)))
@nl8-gh the feature is available on https://tucsky.github.io/aggr for testing
Just a reminder that when, or if, this is approved, documentation will need to be updated here: https://github.com/Tucsky/aggr/wiki/Introduction-to-scripting
Ask | Request: Seeking built-in variable(s) to get / filter sources from within an indicator --> 'Exchange(s)' | 'Type' | 'Currency'
Context: For custom indicators I want to do some math on an e.g. USD Perp for BTC on every supported Exchange. Rather adding them manually / hardcode related sources, a built-in var allows better flexibillity & more.
Benefit: a) Kinda "optimistic" & unified User eXperience since less skilled noobs / users often aren't aware that they need to tweak things (especially on older scripts they might have found). b) developers can provide better defaults (or even, if supported, an option in settings to either use a custom selection only or "all available" (Exchanges | Types | Currencies)