Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Plot 有几个问题:1。打开或关闭枢轴高和低功能。2.更改标签偏移距离_Plot_Switch Statement_Toggle_Pine Script - Fatal编程技术网

Plot 有几个问题:1。打开或关闭枢轴高和低功能。2.更改标签偏移距离

Plot 有几个问题:1。打开或关闭枢轴高和低功能。2.更改标签偏移距离,plot,switch-statement,toggle,pine-script,Plot,Switch Statement,Toggle,Pine Script,我试着编辑前一篇文章来添加这个问题,但我认为没有人看到它,所以这里有一个全新的帖子 -一,。我想关闭和打开蜡烛上方显示的枢轴价格。只是偶尔为了能见度。对函数的以下更改没有任何作用: //@version=4 study(title="testmajiggy", overlay=true) // I've defined the switch "pvhl" on for the pivot high low here. pvhl = input(true, title="pivot hl o

我试着编辑前一篇文章来添加这个问题,但我认为没有人看到它,所以这里有一个全新的帖子

-一,。我想关闭和打开蜡烛上方显示的枢轴价格。只是偶尔为了能见度。对函数的以下更改没有任何作用:

//@version=4
study(title="testmajiggy", overlay=true)

// I've defined the switch "pvhl" on for the pivot high low here. 

pvhl = input(true, title="pivot hl on")
lenH = input(title="Length High", type=input.integer, defval=100, minval=1)
lenL = input(title="Length Low", type=input.integer, defval=100, minval=1)

// then put it in as an argument for the function "fun" down here. I'm not sure if I did it right... 

fun(pvhl, src, len, isHigh, _style, _yloc, _color) =>
    pvhl
    p = nz(src[len])
    isFound = true
    for i = 0 to len - 1
        if isHigh and src[i] > p
            isFound := false

        if not isHigh and src[i] < p
            isFound := false

    for i = len + 1 to 2 * len
        if isHigh and src[i] >= p
            isFound := false

        if not isHigh and src[i] <= p
            isFound := false

    if isFound
        label.new(bar_index[len], p, tostring(p), style=_style, yloc=_yloc, color=_color)

//then I made sure the "fun" call included the pvhl argument in here. 

fun(pvhl, high, lenH, true, label.style_labeldown, yloc.abovebar, color.white)
fun(pvhl, low, lenL, false, label.style_labelup, yloc.belowbar, color.white)
/@version=4
研究(title=“testmajiggy”,overlay=true)
//我在这里为pivot high low定义了开关“pvhl”。
pvhl=输入(真,title=“轴hl打开”)
lenH=input(title=“Length High”,type=input.integer,defval=100,minval=1)
lenL=input(title=“Length Low”,type=input.integer,defval=100,minval=1)
//然后把它作为函数“fun”的参数放在这里。我不确定我是否做对了。。。
乐趣(pvhl、src、len、isHigh、风格、颜色)=>
pvhl
p=nz(src[len])
isFound=true
对于i=0到len-1
如果isHigh和src[i]>p
isFound:=false
如果不是isHigh和src[i]

=p isFound:=false


如果不是isHigh和src[i],则更容易将条件排除在函数之外。另外,如果您不想让指示器显示,则使用“显示/隐藏眼睛”图标隐藏指示器会更快

//@version=4
study(title="testmajiggy", overlay=true)

pvhl = input(true, title="pivot hl on")
lenH = input(title="Length High", type=input.integer, defval=100, minval=1)
lenL = input(title="Length Low", type=input.integer, defval=100, minval=1)
atrM = input(0.5, "Price Offset (Multiple of ATR)", minval = 0.0, step = 0.1)
atrD = atr(5) * atrM

fun(src, len, isHigh, _style, _yloc, _color, _offset) =>
    p = nz(src[len])
    isFound = true
    for i = 0 to len - 1
        if isHigh and src[i] > p
            isFound := false

        if not isHigh and src[i] < p
            isFound := false

    for i = len + 1 to 2 * len
        if isHigh and src[i] >= p
            isFound := false

        if not isHigh and src[i] <= p
            isFound := false

    if isFound
        label.new(bar_index[len], p + _offset, tostring(p), style=_style, yloc=_yloc, color=_color)

if pvhl
    fun(high, lenH, true, label.style_labeldown, yloc.price, color.white, atrD)
    fun(low, lenL, false, label.style_labelup, yloc.price, color.white, -atrD)
/@version=4
研究(title=“testmajiggy”,overlay=true)
pvhl=输入(真,title=“轴hl打开”)
lenH=input(title=“Length High”,type=input.integer,defval=100,minval=1)
lenL=input(title=“Length Low”,type=input.integer,defval=100,minval=1)
atrM=输入(0.5,“价格偏移(ATR的倍数)”,最小值=0.0,步长=0.1)
atrD=atr(5)*atrM
乐趣(src、len、isHigh、_-style、_-yloc、_-color、_-offset)=>
p=nz(src[len])
isFound=true
对于i=0到len-1
如果isHigh和src[i]>p
isFound:=false
如果不是isHigh和src[i]

=p isFound:=false


如果不是isHigh和src[i]ok。非常感谢。我不明白你为什么要使用ATR,但我认为这与标签如何放置在图表附近有关,我猜pinescript的做法是使用价格?但是atr的计算是如此复杂,为什么不使用特定的点或百分比呢?这会使pinescript中的计算速度更快吗?请注意,现在使用的是
yloc.price
。对于这种类型的标签定位,我们需要精确的价格水平来定位标签,而以前使用的
yloc.overbar
yloc.belowbar
没有。将offest计算为ATR的倍数的优点是它使其更通用。它将在比价格百分比更多的图表类型上工作,尽管如果您仅使用价格在相同范围内的图表,也可以使用价格百分比。不,ATR计算并没有真正降低指示器的速度。哦,是的,我忘了问。我想关闭该函数的原因是,如果关闭了该函数,我不会使用tradingview的时间和资源来计算该函数。有办法吗?我尝试了
fun(src、len、isHigh、\u style、\u yloc、\u color、offset)=>pvhl?“此处的其余功能”:na
,这会抛出错误,称为“输入端的语法错误‘行尾无行延续’”,因为您的代码是v4,
fun()
当前不会在
pvhl
设置为
false
时执行,但如果您确实想减少服务器负载,那么,在图表上隐藏指标是最好的做法。我将其设置为另一个指标的一部分,因此如果我使用“眼睛”图标关闭视图,我也会隐藏移动平均值。我只有免费帐户,我只允许3个指标。因此,这是我可以在图表上获得更多指标的一种方法。