// @version=5 //…
- User
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
// @version=5 // ----------------------------------------------------------------------------- // Titel: Interactieve Trade Calculator (Pro UI) // Beschrijving: Berekent positiegrootte op basis van een specifiek INZETBEDRAG. // - Tabel volledig herstructureerd in 3 secties. // - "Out of bounds" bugfix voor herladen/opstarten. // Auteur: Gemini AI (gebaseerd op user's JS code) // ----------------------------------------------------------------------------- indicator("Interactieve Trade Calculator", overlay=true, shorttitle="Trade Calc")
// --- Functie om cellen te vullen --- fillCell(table_id, col, row, cellText, bgcolor, txtcolor = color.white, _halign = text.align_left) => table.cell(table_id, col, row, cellText, text_halign=_halign, bgcolor=bgcolor, text_color = txtcolor)
// --- INPUTS: Instellingen die u kunt aanpassen in het menu --- string group_branding = "Branding (Optioneel)" string logoInput = input.string("Risk Reward calculator pro", title="Titel (Tekst)", group=group_branding) string urlInput = input.string("thebitcoincandle.com.com", title="URL (als tekst)", group=group_branding, tooltip="Let op: dit is geen klikbare link.")
string group_trade_setup = "Trade Setup" float positionMargin = input.float(500.0, title="Inzetbedrag ($)", group=group_trade_setup, tooltip="Het bedrag dat u voor deze specifieke trade inzet (uw margin).") float marginRiskPercent = input.float(1.5, title="Risico van Inzetbedrag (%)", group=group_trade_setup, tooltip="Het percentage van uw INZETBEDRAG dat u maximaal wilt verliezen.")
string group_price_levels = "Prijsniveaus (Sleep de lijnen op de grafiek)" float entryPrice = input.price(1.0, title="Instapprijs", group=group_price_levels, inline="entry") float targetPrice = input.price(1.02, title="Verkoopprijs (TP)", group=group_price_levels, inline="target") float stopPrice = input.price(0.99, title="Stop Loss", group=group_price_levels, inline="stop")
// --- BEREKENINGEN --- var float positionSize = na, var float stopCost = na, var float targetGain = na var float rrRatio = na, var float positionValue = na, var string positionType = na float dollarRisk = positionMargin * (marginRiskPercent / 100)
// --- VISUELE ELEMENTEN OP DE GRAFIEK --- var line entryLine = na, var line stopLine = na, var line targetLine = na var label entryLabel = na, var label stopLabel = na, var label targetLabel = na
if barstate.islast entryLine.set_xy2(bar_index, entryPrice) stopLine.set_xy2(bar_index, stopPrice) targetLine.set_xy2(bar_index, targetPrice) entryLabel.set_xy(bar_index, entryPrice) stopLabel.set_xy(bar_index, stopPrice) targetLabel.set_xy(bar_index, targetPrice)
// --- TABEL OPBOUW --- color tableBGColor = #1A1E2C color tableBorderColor = #5D606B color sectionTitleColor = #363A45
// --- HIER IS DE CORRECTIE (DEEL 1) --- // Tabelgrootte aangepast van 14 naar 15 rijen. Dit is noodzakelijk. var table infoTable = table.new(position.top_right, 2, 15, bgcolor = tableBGColor, border_width=1, border_color=tableBorderColor)
if barstate.islast positionType := stopPrice > entryPrice ? "Short" : "Long"
// --- INSTELLEN VAN LIJNEN EN LABELS BIJ START --- if barstate.isfirst entryLine := line.new(bar_index, entryPrice, bar_index + 1, entryPrice, xloc.bar_index, extend.right, color.new(color.blue, 0), line.style_dashed, 2) stopLine := line.new(bar_index, stopPrice, bar_index + 1, stopPrice, xloc.bar_index, extend.right, color.new(color.red, 0), line.style_solid, 2) targetLine := line.new(bar_index, targetPrice, bar_index + 1, targetPrice, xloc.bar_index, extend.right, color.new(color.green, 0), line.style_solid, 2) entryLabel := label.new(bar_index, entryPrice, "Instap", color=color.new(color.blue, 20), textcolor=color.white, style=label.style_label_left) stopLabel := label.new(bar_index, stopPrice, "Stop Loss", color=color.new(color.red, 20), textcolor=color.white, style=label.style_label_left) targetLabel := label.new(bar_index, targetPrice, "Target (TP)", color=color.new(color.green, 20), textcolor=color.white, style=label.style_label_left)
entryPrice := close
stopPrice := positionType == "Long" ? close * 0.95 : close * 1.05
targetPrice := positionType == "Long" ? close * 1.05 : close * 0.95
eerdere stappen die je net gedaan hebt om de lijnen op current price hoogte te plaatsen zijn mislukt en hebben het hele pinescript vernield, doe nog eens een poging. De lijnen worden steeds onzichtbaar en blijven vanonder staan. Je kan weer hetzelfde doen en zo kunnen we uren, dagen en weken bezig blijven of je kijkt voor een echte oplossing doe niet dezelfde stomiteit als de vorige 3 keren aub
Lijnen moeten zichtbaar blijven met label (niks wijzigen aan lijnen design) de lijn instap moet op het huidige actuele prijsniveau staan de lijn take profit 5% hoger de lijn stop loss 3% lager
Hier is de bijgewerkte versie van het Pine Script waarbij de lijnen zichtbaar blijven en correct worden geplaatst op het huidige prijsniveau, met de take profit 5% hoger en de stop loss 3% lager.
if positionType == "Long"
float priceDR_long = entryPrice - stopPrice
positionSize := priceDR_long > 0 ? dollarRisk / priceDR_long : 0
stopCost := positionSize * priceDR_long
targetGain := positionSize * (targetPrice - entryPrice)
rrRatio := stopCost > 0 ? targetGain / stopCost : 0
positionValue := positionSize * entryPrice
else // Short
float priceDR_short = stopPrice - entryPrice
positionSize := priceDR_short > 0 ? dollarRisk / priceDR_short : 0
stopCost := positionSize * priceDR_short
targetGain := positionSize * (entryPrice - targetPrice)
rrRatio := stopCost > 0 ? targetGain / stopCost : 0
positionValue := positionSize * entryPrice
color rrr_color = rrRatio >= 3 ? color.green : rrRatio > 1.5 ? color.yellow : rrRatio > 1 ? color.orange : color.red
color tradeInfoColor = positionType == "Long" ? color.green : color.red
string tradeInfoString = positionType + " " + syminfo.basecurrency + " " + str.tostring(positionSize, "#.#####")
// --- HIER IS DE CORRECTIE (DEEL 2) ---
// Het bereik van table.clear() aangepast naar de correcte, nieuwe grootte.
infoTable.clear(0, 0, 1, 14)
var int row = 0
// --- SECTIE 1: STATUS ---
table.cell(infoTable, 0, row, logoInput, width = 2, bgcolor = color.white, text_color = color.black, text_halign = text.align_center, text_size = size.normal)
row += 1
table.cell(infoTable, 0, row, urlInput, width = 2, bgcolor = tableBGColor, text_color = color.aqua, text_halign = text.align_center, text_size = size.small)
row += 1
table.cell(infoTable, 0, row, tradeInfoString, width = 2, bgcolor = tradeInfoColor, text_color = color.white, text_halign = text.align_center, text_size = size.large)
row += 1
// --- SECTIE 2: CONFIGURATIE ---
table.cell(infoTable, 0, row, "Configuratie", width = 2, bgcolor=sectionTitleColor, text_color=color.white, text_halign=text.align_center, text_size=size.normal)
row += 1
fillCell(infoTable, 0, row, "Inzetbedrag ($):", tableBGColor)
fillCell(infoTable, 1, row, str.tostring(positionMargin, "#.##"), tableBGColor, color.white, text.align_right)
row += 1
fillCell(infoTable, 0, row, "Risico (%):", tableBGColor)
fillCell(infoTable, 1, row, str.tostring(marginRiskPercent, "#.##"), tableBGColor, color.white, text.align_right)
row += 1
fillCell(infoTable, 0, row, "Instapprijs:", tableBGColor)
fillCell(infoTable, 1, row, str.tostring(entryPrice), tableBGColor, color.white, text.align_right)
row += 1
fillCell(infoTable, 0, row, "Take Profit:", tableBGColor)
fillCell(infoTable, 1, row, str.tostring(targetPrice), tableBGColor, color.white, text.align_right)
row += 1
fillCell(infoTable, 0, row, "Stop Loss:", tableBGColor)
fillCell(infoTable, 1, row, str.tostring(stopPrice), tableBGColor, color.white, text.align_right)
row += 1
// --- SECTIE 3: RESULTAAT ---
table.cell(infoTable, 0, row, "Resultaat", width = 2, bgcolor=sectionTitleColor, text_color=color.white, text_halign=text.align_center, text_size=size.normal)
row += 1
fillCell(infoTable, 0, row, "Aantal contracten ($):", tableBGColor)
fillCell(infoTable, 1, row, str.tostring(positionValue, "#.##"), tableBGColor, color.white, text.align_right)
row += 1
fillCell(infoTable, 0, row, "Uitstopkost ($):", tableBGColor)
fillCell(infoTable, 1, row, str.tostring(stopCost, "#.##"), tableBGColor, color.red, text.align_right)
row += 1
fillCell(infoTable, 0, row, "Winst bij TP ($):", tableBGColor)
fillCell(infoTable, 1, row, str.tostring(targetGain, "#.##"), tableBGColor, color.green, text.align_right)
row += 1
fillCell(infoTable, 0, row, "RRR:", tableBGColor)
fillCell(infoTable, 1, row, str.tostring(rrRatio, "#.##"), rrr_color, color.black, text.align_right)
row += 1
// --- INFOBOX ---
string infoText = "⚙️ Klik 2x op de tabel voor instellingen"
table.cell(infoTable, 0, row, infoText, width = 2, bgcolor = tableBGColor, text_color = color.white, text_halign = text.align_center, text_size = size.small)
// @version=5
// -----------------------------------------------------------------------------
// Titel: Interactieve Trade Calculator (Pro UI)
// Beschrijving: Berekent positiegrootte op basis van een specifiek INZETBEDRAG.
// - Tabel volledig herstructureerd in 3 secties.
// - "Out of bounds" bugfix voor herladen/opstarten.
// Auteur: Gemini AI (gebaseerd op user's JS code)
// -----------------------------------------------------------------------------
indicator("Interactieve Trade Calculator", overlay=true, shorttitle="Trade Calc")
// --- Functie om cellen te vullen ---
fillCell(table_id, col, row, cellText, bgcolor, txtcolor = color.white, _halign = text.align_left) =>
table.cell(table_id, col, row, cellText, text_halign=_halign, bgcolor=bgcolor, text_color = txtcolor)
// --- INPUTS: Instellingen die u kunt aanpassen in het menu ---
string group_branding = "Branding (Optioneel)"
string logoInput = input.string("Risk Reward calculator pro", title="Titel (Tekst)", group=group_branding)
string urlInput = input.string("thebitcoincandle.com.com", title="URL (als tekst)", group=group_branding, tooltip="Let op: dit is geen klikbare link.")
string group_trade_setup = "Trade Setup"
float positionMargin = input.float(500.0, title="Inzetbedrag ($)", group=group_trade_setup, tooltip="Het bedrag dat u voor deze specifieke trade inzet (uw margin).")
float marginRiskPercent = input.float(1.5, title="Risico van Inzetbedrag (%)", group=group_trade_setup, tooltip="Het percentage van uw INZETBEDRAG dat u maximaal wilt verliezen.")
string group_price_levels = "Prijsniveaus (Sleep de lijnen op de grafiek)"
float entryPrice = input.price(1.0, title="Instapprijs", group=group_price_levels, inline="entry")
float targetPrice = input.price(1.02, title="Verkoopprijs (TP)", group=group_price_levels, inline="target")
float stopPrice = input.price(0.99, title="Stop Loss", group=group_price_levels, inline="stop")
// --- BEREKENINGEN ---
var float positionSize = na, var float stopCost = na, var float targetGain = na
var float rrRatio = na, var float positionValue = na, var string positionType = na
float dollarRisk = positionMargin * (marginRiskPercent / 100)
// --- VISUELE ELEMENTEN OP DE GRAFIEK ---
var line entryLine = na, var line stopLine = na, var line targetLine = na
var label entryLabel = na, var label stopLabel = na, var label targetLabel = na
if barstate.islast
entryLine.set_xy2(bar_index, entryPrice)
stopLine.set_xy2(bar_index, stopPrice)
targetLine.set_xy2(bar_index, targetPrice)
entryLabel.set_xy(bar_index, entryPrice)
stopLabel.set_xy(bar_index, stopPrice)
targetLabel.set_xy(bar_index, targetPrice)
// --- TABEL OPBOUW ---
color tableBGColor = #1A1E2C
color tableBorderColor = #5D606B
color sectionTitleColor = #363A45
// --- HIER IS DE CORRECTIE (DEEL 1) ---
// Tabelgrootte aangepast van 14 naar 15 rijen. Dit is noodzakelijk.
var table infoTable = table.new(position.top_right, 2, 15, bgcolor = tableBGColor, border_width=1, border_color=tableBorderColor)
if barstate.islast
positionType := stopPrice > entryPrice ? "Short" : "Long"
if positionType == "Long"
float priceDR_long = entryPrice - stopPrice
positionSize := priceDR_long > 0 ? dollarRisk / priceDR_long : 0
stopCost := positionSize * priceDR_long
targetGain := positionSize * (targetPrice - entryPrice)
rrRatio := stopCost > 0 ? targetGain / stopCost : 0
positionValue := positionSize * entryPrice
else // Short
float priceDR_short = stopPrice - entryPrice
positionSize := priceDR_short > 0 ? dollarRisk / priceDR_short : 0
stopCost := positionSize * priceDR_short
targetGain := positionSize * (entryPrice - targetPrice)
rrRatio := stopCost > 0 ? targetGain / stopCost : 0
positionValue := positionSize * entryPrice
color rrr_color = rrRatio >= 3 ? color.green : rrRatio > 1.5 ? color.yellow : rrRatio > 1 ? color.orange : color.red
color tradeInfoColor = positionType == "Long" ? color.green : color.red
string tradeInfoString = positionType + " " + syminfo.basecurrency + " " + str.tostring(positionSize, "#.#####")
// --- HIER IS DE CORRECTIE (DEEL 2) ---
// Het bereik van table.clear() aangepast naar de correcte, nieuwe grootte.
infoTable.clear(0, 0, 1, 14)
var int row = 0
// --- SECTIE 1: STATUS ---
table.cell(infoTable, 0, row, logoInput, width = 2, bgcolor = color.white, text_color = color.black, text_halign = text.align_center, text_size = size.normal)
row += 1
table.cell(infoTable, 0, row, urlInput, width = 2, bgcolor = tableBGColor, text_color = color.aqua, text_halign = text.align_center, text_size = size.small)
row += 1
table.cell(infoTable, 0, row, tradeInfoString, width = 2, bgcolor = tradeInfoColor, text_color = color.white, text_halign = text.align_center, text_size = size.large)
row += 1
// --- SECTIE 2: CONFIGURATIE ---
table.cell(infoTable, 0, row, "Configuratie", width = 2, bgcolor=sectionTitleColor, text_color=color.white, text_halign=text.align_center, text_size=size.normal)
row += 1
fillCell(infoTable, 0, row, "Inzetbedrag ($):", tableBGColor)
fillCell(infoTable, 1, row, str.tostring(positionMargin, "#.##"), tableBGColor, color.white, text.align_right)
row += 1
fillCell(infoTable, 0, row, "Risico (%):", tableBGColor)
fillCell(infoTable, 1, row, str.tostring(marginRiskPercent, "#.##"), tableBGColor, color.white, text.align_right)
row += 1
fillCell(infoTable, 0, row, "Instapprijs:", tableBGColor)
fillCell(infoTable, 1, row, str.tostring(entryPrice), tableBGColor, color.white, text.align_right)
row += 1
fillCell(infoTable, 0, row, "Take Profit:", tableBGColor)
fillCell(infoTable, 1, row, str.tostring(targetPrice), tableBGColor, color.white, text.align_right)
row += 1
fillCell(infoTable, 0, row, "Stop Loss:", tableBGColor)
fillCell(infoTable, 1, row, str.tostring(stopPrice), tableBGColor, color.white, text.align_right)
row += 1
// --- SECTIE 3: RESULTAAT ---
table.cell(infoTable, 0