Copy a complete input panel into Pine Editor
Add this indicator to a standard time-based chart. When prompted, click a time and price to set the anchor point. The main line uses the chart Source, Length, and Average controls. The optional upper band adds a percentage of the absolute average, so it stays at or above the line even with a negative offset. Reference symbol and timeframe affect only the Data Window reference close. Session shading and the anchor line are separate demonstrations, so changing them does not silently change the moving-average calculation.
- Both averages execute on every bar. The enum selects the output after calculation; disabling the band also explicitly passes na to its plot.
- An empty reference symbol or timeframe uses the chart context in request.security(). A requested open bar can change, and a lower-timeframe request provides limited intrabar information. This diagnostic is not a confirmed trading signal.
- The session uses the exchange timezone by default and all seven days through the explicit 1234567 suffix. Test shading on an intraday chart with bars aligned to the session boundaries.
- The anchor line starts at bars whose opening time is at or after the selected timestamp. A future anchor can leave the entire line absent. Choose a price near the chart to avoid stretching its scale.
//@version=6
indicator("Input panel laboratory", overlay=true)
enum AverageMode
sma = "Simple"
ema = "Exponential"
const string CALC = "Calculation"
const string STYLE = "Appearance"
const string CONTEXT = "Reference and session"
const string ANCHOR = "Interactive anchor"
float sourceInput = input.source(close, "Source", group=CALC)
int lengthInput = input.int(3, "Length", minval=1, maxval=200, step=1, group=CALC)
AverageMode modeInput = input.enum(AverageMode.sma, "Average", group=CALC)
float offsetInput = input(0.0, "Additive offset", group=CALC, tooltip="Price units added after averaging.")
bool showBandInput = input.bool(true, "Upper band", group=CALC, inline="band")
float bandInput = input.float(10.0, "Percent", minval=0.0, maxval=100.0, step=0.5, group=CALC, inline="band", active=showBandInput)
color lineColorInput = input.color(color.blue, "Line", group=STYLE, inline="line")
int widthInput = input.int(2, "Width", options=[1, 2, 3, 4], group=STYLE, inline="line")
string labelInput = input.string("Test A", "Panel label", group=STYLE)
string notesInput = input.text_area("Record one input change at a time.", "Notes", group=STYLE, display=display.none)
string symbolInput = input.symbol("", "Reference symbol", group=CONTEXT)
string timeframeInput = input.timeframe("", "Reference timeframe", group=CONTEXT)
string sessionInput = input.session("0930-1600", "Shade session", group=CONTEXT)
bool shadeInput = input.bool(false, "Show session shading", group=CONTEXT)
int anchorTimeInput = input.time(timestamp("01 Jan 2025 00:00 +0000"), "Time", group=ANCHOR, inline="point", confirm=true)
float anchorPriceInput = input.price(100.0, "Price", group=ANCHOR, inline="point", confirm=true)
float smaValue = ta.sma(sourceInput, lengthInput)
float emaValue = ta.ema(sourceInput, lengthInput)
float average = (modeInput == AverageMode.sma ? smaValue : emaValue) + offsetInput
float upperBand = average + math.abs(average) * bandInput / 100.0
float referenceClose = request.security(symbolInput, timeframeInput, close, ignore_invalid_symbol=true)
bool inSession = not na(time(timeframe.period, sessionInput + ":1234567"))
plot(average, "Selected average", color=lineColorInput, linewidth=widthInput)
plot(showBandInput ? upperBand : na, "Upper band", color=color.orange)
plot(time >= anchorTimeInput ? anchorPriceInput : na, "Anchor price after time", color=color.gray, style=plot.style_linebr)
plot(referenceClose, "Reference close", display=display.data_window)
bgcolor(shadeInput and inSession ? color.new(color.blue, 92) : na)
var table panel = table.new(position.top_right, 1, 3)
if barstate.islast
table.cell(panel, 0, 0, labelInput + " | " + str.tostring(modeInput), text_color=chart.fg_color, bgcolor=chart.bg_color)
table.cell(panel, 0, 1, "Length: " + str.tostring(lengthInput) + " | Band: " + str.tostring(showBandInput), text_color=chart.fg_color, bgcolor=chart.bg_color)
table.cell(panel, 0, 2, notesInput, text_color=chart.fg_color, bgcolor=chart.bg_color)