我做了一个自定义的音量指示器,但是当应用于图表时,它不会像内置的那样自动缩放,不会自动粘在图表面板的底部,也不能没有它自己的显式显示侧面有多余的刻度。
有没有办法做所有这些事情?
我也没有在原始指标代码中找到帮助。例如。当我尝试应用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)
答案 0 :(得分:3)
您问题的简短答案是“否”,目前尚无法做您想做的所有事情。要完成内置的音量独立程序,我们需要做以下两件事:
此代码还使用了Michel的scale.none
的想法,但是它在顶部添加了一个不可见的图,使您可以确定垂直空间中列的最大高度,而无需缩放列本身的值,因此您仍然获得正确的读数。使用*设置/输入”,您可以:
//This indicator 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.
//@version=4
study("Vol in Base asset 20MA", "", true, format.volume, 0, scale.none)
//Make the moving average user configurable
HIM1 = "1. Historical High"
HIM2 = "2. Highest in last..."
showMA = input(true)
scaleFactor = 100 / input(30, "% of vertical space used", step = 10, maxval = 100)
hiMethod = input(HIM2, "High point method", options = [HIM1, HIM2])
hiMethod2Len = input(400, " 2. Length", minval = 2, step = 100)
//Get volume for current bar and multiply with vwap
vInverse = volume * vwap
//Plot fiat volume.
plot(vInverse, color = color.orange, title="VolumeBTC", style=plot.style_columns, transp=0) //Originally: transp=65
//Plot 20 candle moving average (changable in settings)
plot(showMA ? sma(vInverse,20) : na, color = color.white, title="Volume MA", style=plot.style_area, transp=65)
//Plot high line to scale down the columns.
var histHi = 0.
histHi := max(histHi, nz(vInverse, histHi))
limit = hiMethod == HIM1 ? histHi : highest(vInverse, hiMethod2Len)
plot(limit * scaleFactor, "Historical High", #00000000)
有两种方法可以将列的底部置于图表的底部,但没有一种是理想的:
电视已将指示符与垂直空间底部对齐的功能视为一种潜在的改进,但尚无预计到达时间。
答案 1 :(得分:0)
您还缺少其他一些东西。
首先,您应该放置二手松木的版本。有一个特殊的字符串://@version=4
如果未设置该字符串,则该代码被认为是版本1,没有format
参数。
要关闭自动缩放,应将scale
参数设置为scale.none
。请注意,它仅在overlay
参数为true
要使用版本4,颜色应在实际颜色名称color.
之前加上color.orange
前缀,并且绘图样式应在前缀plot.style_
之前加上plot.style_area
< / p>
// NOTE: THE STRING WITH VERSION BELOW IS IMPORTANT!
//@version=4
// to turn the scale off scale.none is used. Note, that it might be only applied
// if the overlay param is 'true'
study(title="Volume", shorttitle="Vol", format=format.volume, overlay=true, scale=scale.none)
showMA = input(true)
vInverse = volume * vwap
// colors must have the prefix 'color.' before the color names
plot(vInverse, color = color.orange, title="VolumeBTC", style=plot.style_columns, transp=65)
plot(showMA ? sma(vInverse,20) : na, color = color.white, title="Volume MA", style=plot.style_area, transp=65)