Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.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
Pine script 即使具有安全功能,该ATR指示器如何避免重新喷漆?_Pine Script - Fatal编程技术网

Pine script 即使具有安全功能,该ATR指示器如何避免重新喷漆?

Pine script 即使具有安全功能,该ATR指示器如何避免重新喷漆?,pine-script,Pine Script,我在重新绘制EMA类型指示器、更平滑的过滤器等方面遇到了严重问题,无论有无安全功能,我都会遇到2分钟或2烛光延迟以及此类冗余;但是,安全功能会导致更多的重新绘制。但是,我有一个ATR指示器,我添加了安全功能,它在任何情况下都不会重新喷漆,也不会延迟两支蜡烛,只有一支正常打开的蜡烛和一支关闭确认的蜡烛 ```pine-script //@version=3 // Copyright (c) 2019-present, Alex Orekhov (everget) // SuperTrend scr

我在重新绘制EMA类型指示器、更平滑的过滤器等方面遇到了严重问题,无论有无安全功能,我都会遇到2分钟或2烛光延迟以及此类冗余;但是,安全功能会导致更多的重新绘制。但是,我有一个ATR指示器,我添加了安全功能,它在任何情况下都不会重新喷漆,也不会延迟两支蜡烛,只有一支正常打开的蜡烛和一支关闭确认的蜡烛

```pine-script
//@version=3
// Copyright (c) 2019-present, Alex Orekhov (everget)
// SuperTrend script may be freely distributed under the terms of the GPL- 
3.0 license.
study("SuperTrend", overlay=true)

length = input(title="ATR Period", type=integer, defval=22)
mult = input(title="ATR Multiplier", type=float, step=0.1, defval=3.0)
showLabels = input(title="Show Buy/Sell Labels ?", type=bool, defval=true)
src = input(title="Source", type=source, defval=close)
timeFrame = input(title="Other time frame", type=string, defval="3")


atr = 0.0
atr := nz(atr[1]) + (src - (nz(atr[1]) + nz(atr[length])) / 2) / length 
////////////



// Retrieve the higher time frame's data





longStopPrev = nz(atr[1], atr)
atr := close[1] > longStopPrev ? max(atr, longStopPrev) : atr


shortStopPrev = nz(atr[1], atr)
atr := close[1] < shortStopPrev ? min(atr, shortStopPrev) : atr

dir = 1
dir := nz(dir[1], dir)
dir := dir == -1 and close > shortStopPrev ? 1 : dir == 1 and close < 
longStopPrev ? -1 : dir

longColor = green
shortColor = red

plot(dir == 1 ? atr : na, title="Long Stop", style=linebr, linewidth=2, 
color=longColor)
buySignal = dir == 1 and dir[1] == -1
plotshape(buySignal ? atr : na, title="Long Stop Start", 
location=location.absolute, style=shape.circle, size=size.tiny, 
color=longColor, transp=0)
plotshape(buySignal and showLabels ? atr : na, title="Buy Label", 
text="Buy", location=location.bottom, style=shape.labelup, size=size.tiny, 
color=longColor, textcolor=white, transp=0)

plot(dir == 1 ? na : atr, title="Short Stop", style=linebr, linewidth=2, 
color=shortColor)
sellSignal = dir == -1 and dir[1] == 1
plotshape(sellSignal ? atr : na, title="Short Stop Start", 
location=location.absolute, style=shape.circle, size=size.tiny, 
color=shortColor, transp=0)
plotshape(sellSignal and showLabels ? atr : na, title="Sell Label", 
text="Sell", location=location.top, style=shape.labeldown, size=size.tiny, 
color=shortColor, textcolor=white, transp=0)
```
```pine脚本
//@版本=3
//版权所有(c)2019年至今,Alex Orekhov(everget)
//SuperTrend脚本可根据GPL-
3.0许可证。
研究(“超趋势”,叠加=真实)
长度=输入(title=“ATR期间”,类型=整数,定义=22)
mult=输入(title=“ATR乘数”,类型=浮点,步长=0.1,微分=3.0)
showLabels=输入(title=“显示购买/出售标签?”,type=bool,deffal=true)
src=输入(title=“Source”,type=Source,deffal=close)
时间范围=输入(title=“其他时间范围”,type=string,deffal=“3”)
atr=0.0
atr:=nz(atr[1])+(src-(nz(atr[1])+nz(atr[length]))/2)/length
////////////
//检索较高时间范围的数据
longStopPrev=nz(atr[1],atr)
atr:=关闭[1]>longStopPrev?最大值(atr,REV):atr
shortStopPrev=nz(atr[1],atr)
atr:=关闭[1]shortStopPrev?1:dir==1并关闭<
朗斯多普雷夫-1:dir
长颜色=绿色
短色=红色
绘图(dir=1?atr:na,title=“长停”,style=linebr,linewidth=2,
颜色=长颜色)
buySignal=dir==1和dir[1]=-1
plotshape(买方信号?atr:na,title=“长停-开始”,
位置=位置.absolute,样式=形状.circle,大小=大小.tiny,
颜色=长颜色,传输=0)
plotshape(购买信号和showLabels?atr:na,title=“购买标签”,
text=“Buy”,location=location.bottom,style=shape.labelup,size=size.tiny,
颜色=长颜色,文本颜色=白色,传输=0)
绘图(dir==1?na:atr,title=“短停”,style=linebr,linewidth=2,
颜色=短色)
sellSignal=dir==-1和dir[1]==1
plotshape(sellSignal?atr:na,title=“短停-启动”,
位置=位置.absolute,样式=形状.circle,大小=大小.tiny,
颜色=短颜色,传输=0)
plotshape(sellSignal和showLabels?atr:na,title=“销售标签”,
text=“Sell”,location=location.top,style=shape.labeldown,size=size.tiny,
颜色=短色,文本颜色=白色,传输=0)
```

Hi,如果您希望获得代码方面的帮助,那么您应该提供一个格式正确(使用代码标记)的、可编译的独立代码段。请注意,为了实现这一点,在顶部包含
/@version=
编译器指令也很重要。我正在努力在编辑器中使用正确的语法标识符来突出显示脚本,例如,关于OP,我所发现的是造成两次蜡烛延迟的原因,我相信是因为我有一堆相互寻找的指标,一个均线寻找另一个均线,通常是3或4个。一旦我添加了第三个,我就得到了冗余,如果它只是一个ema对另一个ema,它将避免问题。您是否也可以在代码中添加如何使用
atr
ema
的安全性?