Search code examples
pine-scriptpine-script-v5tradingview-apipine-script-v4

How was this pop-up coded in pine script?


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.


Solution

  • 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)