在松树脚本中延伸曲线

问题描述 投票:0回答:1

我对 Kaspa(一种加密货币)进行了线性回归,发现它遵循幂律。 我计算了趋势线,它是幂律,形式为价格 = a(时间)^b

我创建了一个简单的交易视图指标,但我只能将该曲线绘制到图表的最后一个柱,并且延伸相同的曲线对我来说似乎是不可能的。 有什么帮助吗?


//@version=5
indicator(title='Kaspa Power Law Bands', shorttitle='KAS Power Law', overlay=true)

// Days X-Axis Value

start = time == timestamp(2022, 06, 01, 0, 0)  // 
days = request.security('CRYPTO:KASUSD', 'D', ta.barssince(start)) 
offset = 205  // days since genesis
d = days + offset

// Power Law Center Line (Regression )

y = math.pow(10, -13.39)*math.pow(d, 4.2654)

// Plot Center, Resistance and Support Lines

p1 = plot(y, title='Center', color=color.new(color.gray, 0), linewidth=2)


我搜索了很多,但无法延长曲线。 我想把这条曲线延长到未来的某个时间,例如5年或10年。 公式为价格=(10^-13.39)(d^4.2654)

pine-script pine-script-v5 tradingview-api cryptocurrency
1个回答
0
投票

我无法帮助您使用数学公式,但请尝试从最近 10 个周期延长一条线。

var line lineExtend = na
if barstate.islast
    lineExtend := line.new(
      x1     = bar_index[10],
      y1     = y[10],
      x2     = bar_index,
      y2     = y,
      xloc   = xloc.bar_index,
      extend = extend.right,
      color  = color.new(color.gray, 0),
      width  = 2)
    line.delete(lineExtend[1])

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.