pine-script - TradingView {{close}} 不适用于警报、纯文本
问题描述
我想让https://www.tradingview.com/script/whJATyGU-UT-Bot/这个机器人更有用,但我遇到了一些问题,希望你能帮助我。
代码是用纯文本编写的。
我已经修改了如下代码,(只是添加了两行代码以创建警报)
study(title="VET Bot", overlay = true)
SOURCE = input(hlc3)
RSILENGTH = input(14, title = "RSI LENGTH")
RSICENTERLINE = input(52, title = "RSI CENTER LINE")
MACDFASTLENGTH = input(7, title = "MACD FAST LENGTH")
MACDSLOWLENGTH = input(12, title = "MACD SLOW LENGTH")
MACDSIGNALSMOOTHING = input(12, title = "MACD SIGNAL SMOOTHING")
a = input(1, title = "Key Vaule")
SmoothK = input(3)
SmoothD = input(3)
LengthRSI = input(14)
LengthStoch = input(14)
RSISource = input(close)
c = input(9, title="ATR Period")
xATR = atr(c)
nLoss = a * xATR
xATRTrailingStop = iff(close > nz(xATRTrailingStop[1], 0) and close[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), close - nLoss),
iff(close < nz(xATRTrailingStop[1], 0) and close[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), close + nLoss),
iff(close > nz(xATRTrailingStop[1], 0), close - nLoss, close + nLoss)))
pos = iff(close[1] < nz(xATRTrailingStop[1], 0) and close > nz(xATRTrailingStop[1], 0), 1,
iff(close[1] > nz(xATRTrailingStop[1], 0) and close < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0)))
color = pos == -1 ? red: pos == 1 ? green : blue
ema= ema(close,1)
above = crossover(ema,xATRTrailingStop )
below = crossover(xATRTrailingStop,ema)
buy = close > xATRTrailingStop and above
sell = close < xATRTrailingStop and below
barbuy = close > xATRTrailingStop
barsell = close < xATRTrailingStop
alertcondition(buy, title='Al', message = 'Al')
alertcondition(sell, title='Sat', message = 'Sat')
plotshape(buy, title = "Al", text = 'Al', style = shape.labelup, location = location.belowbar, color= green,textcolor = white, transp = 0, size = size.tiny)
plotshape(sell, title = "Sat", text = 'Sat', style = shape.labeldown, location = location.abovebar, color= red,textcolor = white, transp = 0, size = size.tiny)
barcolor(barbuy? green:na)
barcolor(barsell? red:na)
为了使用我创建的警报,我必须更改警报屏幕上的警报条件,如附加图像。
我的问题从这里开始,一般来说,当我在 TradingView 上使用默认警报时,我可以使用 {{close}} 变量来达到柱的收盘价但是,如果我使用我编辑过的脚本,我将无法使用它并且消息似乎是这样的;
(COINBASE:BTCUSD, m1), 价格 = {{close}}
m1 是警报的时间范围,在这种情况下为 1 分钟。
有谁知道如何使用 {{close}} 变量或任何想法来达到价格?
我还尝试在如下代码中更改警报的消息部分,但随后在警报屏幕上出现错误。
此致,
alertcondition(buy, title='Al', message = 'Al @' + tostring(close))
解决方案
{{close}}
仅适用于@version=4
但是,一旦你把@version=4
代码放在顶部,你会得到很多错误,因为你的一些代码不能被@version=4
. 您必须将它们转换为@version=4
.
推荐阅读
- java - 检查 Android Studio 中的电子邮件和用户名可用性(Firebase)
- android - 如果 ValueEventListener 没有从活动 onDestroy firebase 实时数据库中删除会发生什么
- javascript - 使用 javascript 抓取 Google 翻译 Chrome 扩展程序显示的 popup.html
- javascript - 如何在捕获时终止函数执行?
- java - Selenium 测试用例对于通过 ajax 提交的表单失败
- arrays - 如何编写一个由 Log4j2 JSONLayout 自动转换为 JSON 的 Java 类?
- html - 为什么我的 div 的截止角不平滑?
- xamarin - 相同的列表视图 2 个不同的页面
- c# - 如何统一处理随机产生的障碍物?
- javascript - 比较滑块 img 文本消失,然后在文本上或后面滑动