且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在松树编辑器中查找时间范围的最高和最低值

更新时间:2023-10-27 17:36:16

//@version=4
study(title="Help (Test)")

biggest(series) =>
    max = 0.0
    max := nz(max[1], series)
    if series > max
        max := series
    max

smallest(series) =>
    min = 0.0
    min := nz(min[1], series)
    if series < min
        min := series
    min

fast = 14, slow = 50

length = input(fast, minval=1)
src = input(close, title="Source")
e1 = ema(src, length)
e2 = ema(e1, length)
dema = 2 * e1 - e2

band4 = hline(0, "Upper Band", color=#ff0000)

fastEMA = ema(close, fast)
slowEMA = ema(close, slow)
test = (dema - slowEMA)//(high1-low1)
plot(test,color=color.black)

//[ADDON]
period = input("6M", "Period hi/lo detect", input.resolution) //  Six Months

var hi = 0.0
var lo = 10e10
var br = 0
var lnhi = line.new(na, na, na , na)
var lnlo = line.new(na, na, na , na)

if change(time(period))
    hi := test
    lo := test
    br := bar_index
    lnhi := line.new(br, hi , br, hi, color=color.red, width=2)
    lnlo := line.new(br, lo , br, lo, color=color.green, width=2)
    float(na)
else
    hi := max(test, hi)
    lo := min(test, lo)

line.set_xy1(lnhi, br, hi)
line.set_xy2(lnhi, bar_index, hi)
line.set_xy1(lnlo, br, lo)
line.set_xy2(lnlo, bar_index, lo)

您的情节 test 使用 6 个月时间范围内的绝对最高和最低值.

Your plot test with the ABSOLUTE HIGHEST and LOWEST value for six months time frames.