我制作了一个自定义的成交量指标,但在应用于图表时,它不像内置指标一样自动缩放,也不能自动固定在图表面板底部,还需要自己显式添加额外的刻度。
有没有办法让它做到这些事情?
我在原始指标代码中也没有找到任何帮助。例如,当我尝试应用format.volume时,它根本无法编译。
以下是我的代码,原始代码在下面:
//This inddicator will show volume inversely. So if you are looking at an Altcoin, it will show volume in BTC, if you are looking at for example BTC/USD it will show volume in USD and so on. Works with all altcoins and fiat pairs.
//I find this most useful when shopping for alts to quickly get an idea of their liquidity.
//title the indicator and dont use decimals. (Otherwise when viewing fiat volume you get unreadably large numbers) you can change this in the settings dialog tho if you want.
study("Vol in Base asset 20MA", precision=0)
//Make the moving average user configurable
showMA = input(true)
//Get volume for current bar and multiply with vwap
vInverse = volume * vwap
//Plot fiat volume.
plot(vInverse, color = orange, title="VolumeBTC", style=columns, transp=65)
//Plot 20 candle moving average (changable in settings)
plot(showMA ? sma(vInverse,20) : na, color = white, title="Volume MA", style=area, transp=65)
原始代码:
//@version=4
study(title="Volume", shorttitle="Vol", format=format.volume)
showMA = input(true)
barColorsOnPrevClose = input(title="Color bars based on previous close", type=input.bool, defval=false)
palette = barColorsOnPrevClose ? close[1] > close ? color.red : color.green : open > close ? color.red : color.green
plot(volume, color = palette, style=plot.style_columns, title="Volume", transp=65)
plot(showMA ? sma(volume,20) : na, style=plot.style_area, color=color.blue, title="Volume MA", transp=65)