TradingView {{close}}不适用于警报,纯文本

时间:2019-11-23 16:52:02

标签: plaintext alerts tradingview-api

我想使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)

要使用我创建的警报,我必须在警报屏幕上更改警报条件,如附加的图像。

enter image description here

我的问题从这里开始,通常,当我在TradingView上使用默认警报时,我可以使用{{close}}变量来达到该条的收盘价,但是,如果我使用自己编辑的脚本,则无法使用它和消息看起来像那样;

  

(COINBASE:BTCUSD,m1),价格= {{close}}

m1是警报的时间范围,在这种情况下为1分钟。

有人知道如何使用{{close}}变量,或者有任何想法可以达到价格吗?

我还试图在如下代码中更改警报的消息部分,但随后在警报屏幕上出现错误。

最诚挚的问候,

alertcondition(buy, title='Al', message = 'Al @' + tostring(close))

enter image description here

1 个答案:

答案 0 :(得分:0)

@PostConstruct private void init() throws SQLException { System.out.println("\n\n\n\n\n\n"); EntityManagerFactoryInfo info = (EntityManagerFactoryInfo) entityManager.getEntityManagerFactory(); Connection connection = Objects.requireNonNull(info.getDataSource()).getConnection(); CallableStatement stmt = connection.prepareCall("{ ? = call dbINFO()}"); stmt.registerOutParameter(1, OracleTypes.CURSOR); stmt.execute(); ResultSet rs = (ResultSet) stmt.getObject(1); while (rs.next()){ System.out.println(rs.getCursorName()); } rs.close(); stmt.close(); System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); } 仅适用于{{close}} 但是,一旦将@version=4放在代码的顶部,您将遇到很多错误,因为@version=4无法识别您的某些代码。您将不得不将其转换为@version=4