Percentage Buy, Target, Stop + Overlay
This tool helps traders plan entries and exits using fixed percentage offsets instead of volatility. It plots Buy, Target, and Stop levels on the chart based on a user‑defined entry price and simple percentage multipliers—giving a clear, objective framework for risk/reward.
NOTE: To activate the lines and table, enter a Buy Price greater than zero.
What It Does
Buy Price Input: Manually enter your intended entry price (e.g. planned or executed trade).
Percentage‑Based Target and Stop:
Target Price = Buy × (1 + Target % / 100)
Stop Price = Buy × (1 – Stop % / 100)
Visual Overlay: Draws horizontal lines at Buy, Target, and Stop levels on your chart.
Interactive Table: Displays Buy, Target, Stop and their percentages in a customizable on‑chart table.
Customization Options
Line Settings
Choose color, style (solid/dashed/dotted), and width for each line.
Extend lines to the right only or both directions.
Table Settings
Position table (top/bottom × left/right).
Toggle rows for Buy, Target, Stop, and percentage values.
Adjust text colors and background transparency.
How to Use It for Trading
Plan Your Trade: Enter your entry price.
Set Exits: Specify target and stop percentages to instantly see risk/reward zones.
Visual Reference: Lines update in real time as you adjust inputs—ideal for live monitoring or backtesting.
Straightforward Risk Management: Fixed percentages offer a simple alternative when ATR or volatility‑based levels aren’t preferred.
Ideal For
Traders who prefer fixed percentage targets/stops
Quick risk/reward visualization
Beginners seeking a clear, rule‑based exit framework
Any trader wanting an alternative to volatility‑based sizing
// Percentage Buy, Target, Stop + Overlay
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0
// © abbadon9 [If you modify this script please acknowledge me.]
//@version=6
indicator("Percentage Buy, Target, Stop + Overlay", shorttitle="% BTS", overlay=true)
// === INPUTS ===
buyPriceInput = input.float(title="Buy Price (enter > 0)", defval=0.0)
targetPct = input.float(title="Target Percentage (%)", defval=1.5)
stopPct = input.float(title="Stop Percentage (%)", defval=0.5)
// === Line Extension Input ===
extendBoth = input.bool(false, title="Extend Lines Both Directions", group="Line Settings")
extendOption = extendBoth ? extend.both : extend.right
// === Buy Line Inputs ===
buyLineColor = input.color(color.green, title="Buy Line Color", group="Line Settings")
buyLineStyleStr= input.string("dotted", title="Buy Line Style", options=["solid","dashed","dotted"], group="Line Settings")
buyLineWidth = input.int(1, title="Buy Line Width", minval=1, maxval=5, group="Line Settings")
buyLineStyle = buyLineStyleStr=="dotted"?line.style_dotted:buyLineStyleStr=="dashed"?line.style_dashed:line.style_solid
// === Target Line Inputs ===
targetLineColor = input.color(color.blue, title="Target Line Color", group="Line Settings")
targetLineStyleStr= input.string("dotted", title="Target Line Style", options=["solid","dashed","dotted"], group="Line Settings")
targetLineWidth = input.int(1, title="Target Line Width", minval=1, maxval=5, group="Line Settings")
targetLineStyle = targetLineStyleStr=="dotted"?line.style_dotted:targetLineStyleStr=="dashed"?line.style_dashed:line.style_solid
// === Stop Line Inputs ===
stopLineColor = input.color(color.red, title="Stop Line Color", group="Line Settings")
stopLineStyleStr= input.string("dotted", title="Stop Line Style", options=["solid","dashed","dotted"], group="Line Settings")
stopLineWidth = input.int(1, title="Stop Line Width", minval=1, maxval=5, group="Line Settings")
stopLineStyle = stopLineStyleStr=="dotted"?line.style_dotted:stopLineStyleStr=="dashed"?line.style_dashed:line.style_solid
// === Table Text Colors ===
buyTextColor = input.color(color.green, title="Buy Text Color", group="Table Settings")
targetTextColor = input.color(color.blue, title="Target Text Color", group="Table Settings")
stopTextColor = input.color(color.red, title="Stop Text Color", group="Table Settings")
// === Percentage Calculation ===
validBuy = buyPriceInput > 0
// === Price Levels ===
buyPrice = validBuy ? buyPriceInput : na
targetPrice = validBuy ? buyPrice * (1 + targetPct/100) : na
stopPrice = validBuy ? buyPrice * (1 - stopPct/100) : na
// === Line Variables ===
var line buyLine = na
var line targetLine = na
var line stopLine = na
if barstate.islast
if not na(buyLine)
line.delete(buyLine)
if not na(targetLine)
line.delete(targetLine)
if not na(stopLine)
line.delete(stopLine)
if validBuy
buyLine := line.new(bar_index, buyPrice, bar_index+1, buyPrice, color=buyLineColor, width=buyLineWidth, style=buyLineStyle)
targetLine := line.new(bar_index, targetPrice, bar_index+1, targetPrice, color=targetLineColor, width=targetLineWidth, style=targetLineStyle)
stopLine := line.new(bar_index, stopPrice, bar_index+1, stopPrice, color=stopLineColor, width=stopLineWidth, style=stopLineStyle)
line.set_extend(buyLine, extendOption)
line.set_extend(targetLine, extendOption)
line.set_extend(stopLine, extendOption)
// === Table Settings Inputs ===
bg_col = input.color(color.new(color.black, 100), title="Background Color", group="Table Settings")
showTableHeader = input.bool(true, title="Add Empty Top Spacer Row", group="Table Settings")
tablePositionOption = input.string("bottom_right", title="Table Position", options=["top_right","top_left","bottom_right","bottom_left"], group="Table Settings")
// === Table Row Toggles ===
showBuyRow = input.bool(true, title="Show Buy Row", group="Table Settings")
showTargetRow = input.bool(true, title="Show Target Row", group="Table Settings")
showStopRow = input.bool(true, title="Show Stop Row", group="Table Settings")
// Map string to position constant
tablePos = tablePositionOption=="top_right"?position.top_right:
tablePositionOption=="top_left"?position.top_left:
tablePositionOption=="bottom_right"?position.bottom_right:
position.bottom_left
// Determine visible rows
visibleRowCount = (showBuyRow?1:0) + (showTargetRow?1:0) + (showStopRow?1:0)
rowsCount = visibleRowCount + (showTableHeader?1:0)
// === Table ===
var table infoTable = table.new(tablePos, 2, rowsCount, border_width=1)
if validBuy
rowOffset = showTableHeader ? 1 : 0
if showTableHeader
table.cell(infoTable, 0, 0, "", bgcolor=bg_col)
table.cell(infoTable, 1, 0, "", bgcolor=bg_col)
row = rowOffset
if showBuyRow
table.cell(infoTable, 0, row, "Buy Price", text_color=buyTextColor)
table.cell(infoTable, 1, row, str.tostring(buyPrice, "#.##"), text_color=buyTextColor)
row += 1
if showTargetRow
table.cell(infoTable, 0, row, "Target (" + str.tostring(targetPct) + "%)", text_color=targetTextColor)
table.cell(infoTable, 1, row, str.tostring(targetPrice, "#.##"), text_color=targetTextColor)
row += 1
if showStopRow
table.cell(infoTable, 0, row, "Stop (" + str.tostring(stopPct) + "%)", text_color=stopTextColor)
table.cell(infoTable, 1, row, str.tostring(stopPrice, "#.##"), text_color=stopTextColor)
else
table.clear(infoTable, 0, 0)