分享一下9转序列(TD9)的tradingview code

来源: 2024-07-28 15:53:37 [旧帖] [给我悄悄话] 本文已被阅读:

这个TD9 indicator好像因为版权问题在tradingview下架了。搜了一下没搜到现成代码,于是自己diy了一个。有需要的自取。 :)

//@version=5
indicator("MyTd", overlay = true)
var cup = 0
var cdown = 0
if close > close[4]
    cup := cup + 1
    cdown := 0
else
    cdown := cdown + 1
    cup := 0
if cup > 0
    label.new(bar_index, high, text = str.tostring(cup), yloc = yloc.abovebar, style = label.style_none, textcolor = color.green)
if cdown > 0
    label.new(bar_index, high, text = str.tostring(cdown), yloc = yloc.belowbar, style = label.style_none, textcolor = color.red)

 

图形效果是这样子的。 (btw, qq已经到down trend 12了,快苦尽甘来了 :)。 根据对称性,上次up trend是12转的,当然上上次是18)。