我正在尝试在 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)
提前感谢任何指导。