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

如何在Pine Script中实现设置入场/止损后的输入弹窗?

Pine Script实现自定义输入弹窗方案

我正在使用Pine Script开发TradingView平台的仓位大小计算器指标,当前功能正常,但需要新增一项功能:在图表上设置入场价(entryPrice)和止损价(stopLossPrice)后,弹出可输入内容的弹窗(非通过设置框触发)。已有同类指标实现了该功能,以下是我的现有代码:

//@version=5
indicator("MZD Lot Size Calculator", max_bars_back=100, overlay=true, linktoseries=true, scale=scale.none, precision=5, format=format.price)

toString(x)=> str.tostring(x)
numberToLotSizeFormat(size) => str.format("{0,number,#.##}", size)
roundPrice(price) => math.round(price, 5)

getTicksForNR(stopLossTickSize, commission, rCount) => stopLossTickSize * rCount + commission * rCount + commission

getPriceForNR(entryPrice, stopLossPrice, ticks, mintick) => roundPrice(entryPrice > stopLossPrice ? entryPrice + (ticks * mintick) : entryPrice - (ticks * mintick))

// USER SETTINGS GROUPS
PRICE_LEVELS_GROUP = "Entry & SL Price"
RISK_MANAGE_GROUP = 'Risk Manager'
TABLE_APPEARANCE_GROUP = 'Table appearance'


// RISK MANAGER
accountSize = input(100000, 'Account Size in $', group=RISK_MANAGE_GROUP)
risk = input.float(1, title='Risk in %', group=RISK_MANAGE_GROUP)
commission = input.float(3, title='Commission in $', group = RISK_MANAGE_GROUP)

entryPrice = roundPrice(input.price(defval = 1.00000, title = 'Entry Price   ', group = PRICE_LEVELS_GROUP, inline= '1', confirm = true))
entryColor = input.color(color.green, title = '', inline= '1', group = PRICE_LEVELS_GROUP)

stopLossPrice = roundPrice(input.price(defval = 0.99950, title = 'Stop Price    ', group = PRICE_LEVELS_GROUP, inline= '2', confirm = true))
stopLossColor = input.color(defval = color.red  , title = '', inline= '2', group = PRICE_LEVELS_GROUP)

此前咨询ChatGPT得知Pine Script无此实现方式,现询问该弹窗的具体实现代码。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.21 06:37:04