首页 > 解决方案 > 松脚本趋势线获取当前价格问题

问题描述

我有以下脚本:

s1_first_line2 := trend_s1_line_extend ? line.new(
  sm_bag_ready ? s1T_fx : na,
  sm_bag_ready ? s1T_fy : na,
  sm_bag_ready ? s1T_tx : na,
  sm_bag_ready ? s1T_ty : na,
  extend = extend.right,
  xloc = xloc.bar_time,
  color = trend_s1_use_colors == false ? trend_s1_color_default : 
  (sTriDir == 1) ? trend_s1_line_color_up : trend_s1_line_color_dn,
  style = trend_s1_xline_style,
  width = trend_s1_xline_width) : na
//  }}}

currentLineValue = line.get_price(s1_first_line2, bar_index)

我无法获得趋势线的当前价格。它给出了错误:

line.get_price 必须与使用 xloc=xloc.bar_index 创建的行一起使用

我怎样才能使当前价格高于趋势线?

最好的

标签: pine-scripttrendline

解决方案


startPrice = line.get_y1(id=line1) endPrice = line.get_y2(id=line1)


推荐阅读