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

从V2迁移至V4时出现Too much arguments错误的原因排查求助

Fixing "Too much arguments converting from V2 to V4" in Pine Script

I’ve run into this exact snag when migrating Pine Script code from V2 to V4—let’s break down what’s going wrong and how to fix it quickly.

The Root Cause

Your error comes from a breaking change in how Pine Script handles color definitions between versions:

  • In V2, you could use the color() function with 1 or 2 arguments (like color(color.red) or color(color.red, 50)) to define base colors or semi-transparent ones.
  • In V4, this syntax was retired. Instead:
    • Native color constants like color.red are already valid color values—you don’t need to wrap them in an extra color() call.
    • To create a color with transparency, you must use the color.new() function (note: the second argument here is transparency, where 0 = fully opaque and 100 = fully transparent).

Fixed Code

Swap your original line with this corrected version:

colors = cond1 ? color.red : cond2 ? color.new(color.aqua, 50) : color.new(color.red, 50)

Why This Works

  • We remove the redundant color() wrapper around color.red (since it’s already a valid color value in V4).
  • We use color.new() for the semi-transparent colors, which matches V4’s required API syntax.
  • This eliminates the "too many arguments" error because we’re now using the function signatures that V4 expects.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.30 14:02:32