2

我正在尝试在 Tradingview 上编写一个 pine 脚本代码,目的是自动调整 renko 框大小(类似于 ATR,但 tradingview 的 ATR 功能不能满足我的要求),我正在考虑将框大小设为 5%当前价格(或前一个收盘价,这更有意义,因为该值是具体的)。

下面是常规 renko 的代码,我正在努力使“box_size”变量等于前一个收盘价的特定百分比。

//@version=3
study("Renko", shorttitle = "Renko")
src = input(title = "Source (close or open or hl2 or hlc3 or ohlc4)", type = 
string, defval = "close") 
box_size = 0.5
renko_tickerid = renko(tickerid, src, "Traditional", box_size)
renko_close = security(renko_tickerid, period, close)
renko_open = security(renko_tickerid, period, open)
renko_high = security(renko_tickerid, period, high)
renko_low = security(renko_tickerid, period, low)
plotcandle(renko_open, renko_high, renko_low, renko_close, color = renko_open < renko_close ? green : red)

提前感谢任何指导。

4

2 回答 2

0

将此添加到您的代码中,它应该实现您正在寻找的内容:

size=input(2)
renko_tickerid = renko(syminfo.tickerid, "Traditional", size)

请记住,在 TradingView 中,最小盒子大小为 1 点(例如对于纳斯达克期货,它是 0.25,盒子大小必须是 0.25 的倍数)

于 2019-07-30T17:56:26.700 回答
0

试试这个

//@version=3
study("Renko", shorttitle = "Renko")
src = input(title = "Source (close or open or hl2 or hlc3 or ohlc4)", type = 
string, defval = "close")
percentate_value = 0.01   // 1/100 =0.01 1%   
box_size = nz(close[1]*percentate_value, 0)

renko_tickerid = renko(tickerid, src, "Traditional", box_size)
renko_close = security(renko_tickerid, period, close)
renko_open = security(renko_tickerid, period, open)
renko_high = security(renko_tickerid, period, high)
renko_low = security(renko_tickerid, period, low)
plotcandle(renko_open, renko_high, renko_low, renko_close, color = renko_open < renko_close ? green : red)

这里 close[1] 是前一个收盘价 nz(close[1] percentate_value, 0) 当没有前一个值时返回零 else previousclose precentage_value

于 2018-11-18T11:49:58.987 回答