You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Pine Script V5代码报错求助:未声明标识符与defval参数未赋值

修正Pine Script V5自由流通量绘图代码

错误原因分析

  • 调用input.float()时,无需额外指定type=input.float参数,这个冗余写法触发了"未声明标识符'input'"报错
  • input.float()是必填defval参数(默认值)的函数,原代码未提供该参数,导致出现"未赋值defval参数"的错误

修正后的代码

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Mailbin

//@version=5
indicator("Free Float", overlay=true)
// 移除多余type参数,补充必填的默认值参数
shares_outstanding = input.float(title="Shares Outstanding", defval=0)
shares_available_for_trading = input.float(title="Shares Available for Trading", defval=0)
free_float = (shares_available_for_trading / shares_outstanding) * 100
plot(free_float, title="Free Float", color=color.green, linewidth=2)

补充说明

  • input.float()本身已限定输入类型为浮点型,不需要额外声明type参数
  • defval=0可根据实际需求替换为合理的默认数值,后续也能在指标设置面板手动修改这两个数值,计算对应股票的自由流通比例

内容的提问来源于stack exchange,提问作者Zipzip

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 04:02:03