我制作了一个自定义交易量指标,但是当应用于图表时,它不会像内置指标那样自动缩放,不会自动粘在图表面板的底部,也不能没有自己明确的额外刻度旁边。
有没有办法让它做所有这些事情?
我在原始指标代码中也没有找到任何帮助。例如,当我尝试应用 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)
Run Code Online (Sandbox Code Playgroud)
原始代码:
//@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)
Run Code Online (Sandbox Code Playgroud)
对您的问题的简短回答是否定的,目前无法做您想做的一切。要完成内置音量独立游戏的功能,我们需要两件我们没有的东西:
这段代码也使用了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)
Run Code Online (Sandbox Code Playgroud)
有两种方法可以将列的底部带到图表底部,但没有一种方法是理想的:
TV 认为将指示器与垂直空间底部对齐的能力是一项潜在的改进,但目前还没有 ETA。
还有一些您错过的其他事情。
首先,你应该输入使用的pine的版本。有一个特殊的字符串://@version=4如果未设置该字符串,则代码将被视为没有参数的版本 1 format。
要关闭自动缩放,您应该将scale参数设置为scale.none。请注意,仅当参数overlay为true
要使用版本 4,颜色应color.在实际颜色名称之前具有前缀:color.orange,并且绘图样式应具有前缀plot.style_:plot.style_area
// 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)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14170 次 |
| 最近记录: |