这个弹出窗口是如何在 Pine Script 中编写的?

huangapple go评论45阅读模式
英文:

How was this pop-up coded in pine script?

问题

I understand your request. Here's the translated portion of your text:

"我正在使用Pine Script在TradingView中开发一个批量大小计算器指标。目前它正在工作,除了在图表上设置入场价和止损价时我想显示弹出或对话框。有一个指标可以做到这一点(明确一下,是在操作完成后弹出一个对话框,您可以在其中提供输入,而不是点击设置框)。我将提供已经实现了这一功能的指标的截图以及我的代码。谢谢!"
屏幕录制指标

//@version=5
indicator("MZD批量大小计算器", 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))

// 用户设置组
PRICE_LEVELS_GROUP = "入场 & 止损价"
RISK_MANAGE_GROUP = '风险管理'
TABLE_APPEARANCE_GROUP = '表格外观'

// 风险管理
accountSize = input(100000, '账户大小(美元)', group=RISK_MANAGE_GROUP)
risk = input.float(1, title='风险百分比', group=RISK_MANAGE_GROUP)
commission = input.float(3, title='佣金(美元)', group = RISK_MANAGE_GROUP)

entryPrice = roundPrice(input.price(defval = 1.00000, title = '入场价   ', 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 = '止损价   ', inline= '2', group = PRICE_LEVELS_GROUP, confirm = true))
stopLossColor = input.color(defval = color.red  , title = '', inline= '2', group = PRICE_LEVELS_GROUP)

我明白你的要求,只翻译代码和特定的文本部分,不提供其他内容或回答问题。

英文:

im developing a lot size calculator indicator in tradingview using pine script.
it's working right now except for the pop-up or dialog box i want to show whenever u have set the entry and stop-loss on the chart. there is a indicator that does this (to be clear a pop-up after a action is done where you can give input not clicking on the settings box.) i will provide screenshots of the indicator that already has done this and my code. thanks!
screenrecording indicator

//@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    ', inline= '2', group = PRICE_LEVELS_GROUP, confirm = true))
stopLossColor = input.color(defval = color.red  , title = '', inline= '2', group = PRICE_LEVELS_GROUP)


i tried asking chatGPT but it keeps telling me that there is no option in pine script where this is possible.

答案1

得分: 0

你的代码看起来没问题,并按你要求运行。confirm = true 是创建弹出窗口的部分。我复制并粘贴了你的代码,当我将其添加到我的图表时,弹出窗口出现了。

如果你说的是选择两个价格后弹出的窗口,那么你需要在另一个输入中添加 confirm。例如,如果你在此处将其添加到 entry color,它将在选择输入和止损价格后弹出窗口。

entryColor = input.color(color.green, title = '', inline= '1', group = PRICE_LEVELS_GROUP, confirm = true)
英文:

Your code looks right and works as you ask. The confirm = true is what creates the pop up. I copied and pasted your code and I was prompted with the pop up when I added it to my chart.

If you are talking about the pop up after selecting your two prices, then you would need to add a confirm to another input. For example if you add it here to the entry color it will bring up the window after selecting both your entry and stop prices.

entryColor = input.color(color.green, title = '', inline= '1', group = PRICE_LEVELS_GROUP, confirm = true)

huangapple
  • 本文由 发表于 2023年5月22日 05:41:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/76302040.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定