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

Pine Script算术限价单设置:如何按前K线低价下浮1%挂多单

Pine Script 限价单价格计算修正方案

原代码问题说明

你写的low[1] * -0.01存在算术逻辑错误,该表达式会返回前一根K线最低价乘以-0.01的负数值,完全不符合「下浮1%」的需求。

正确算术表达式

下浮1%的本质是取原价格的99%,有两种等价写法:

  • 简化写法:low[1] * 0.99
  • 拆分逻辑写法:low[1] - low[1] * 0.01

修正后完整代码

if ta.barssince(enterLong) < 3
    strategy.entry(id="EL", direction=strategy.long, limit=low[1] * 0.99)

补充优化建议

如果交易标的对报价精度要求较高,可使用ta.round_to_mintick()函数将计算结果对齐到标的允许的最小报价单位,避免限价单因价格精度问题无法正常挂单:

if ta.barssince(enterLong) < 3
    strategy.entry(id="EL", direction=strategy.long, limit=ta.round_to_mintick(low[1] * 0.99))

内容的提问来源于stack exchange,提问作者Mr.X

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.25 14:45:04