Since you trade 1-minute and 5-minute price action and look for liquidity sweeps, I have included a basic sweep/rejection pattern as the placeholder logic.
Code: Select all
//@version=5
indicator("Discipline Guardrail [Mistake Filter]", overlay=true)
// =========================================================================
// 1. INPUTS & PARAMETERS
// =========================================================================
grp_time = "Session & Time Filters"
// Default set to London / NY Overlap (adjust to your local timezone)
sessionTime = input.session("0800-1130", title="Allowed Trading Session", group=grp_time)
timeZone = input.string("America/New_York", title="Timezone", group=grp_time)
// =========================================================================
// 2. TIME & SESSION LOGIC (Fixes: Dead-zone trading)
// =========================================================================
inSession = not na(time(timeframe.period, sessionTime, timeZone))
// Paint the chart background dark red if you are outside the trading session
bgcolor(not inSession ? color.new(color.red, 92) : na, title="Out of Session Warning")
// =========================================================================
// 3. STRATEGY LOGIC (Placeholder: Liquidity Sweep / Pin Bar)
// =========================================================================
// Replace this section with your specific price-action trigger
totalRange = high - low
upperWick = high - math.max(close, open)
lowerWick = math.min(close, open) - low
// Basic Sweep: Took out previous candle's extreme, but rejected heavily
bullishSweep = (lowerWick > totalRange * 0.5) and (low < low[1]) and (close > open)
bearishSweep = (upperWick > totalRange * 0.5) and (high > high[1]) and (close < open)
// =========================================================================
// 4. THE MISTAKE FILTER (Fixes: Premature Entry / FOMO)
// =========================================================================
// barstate.isconfirmed is the engine of the script. It evaluates to TRUE
// ONLY on the exact tick that the 1m or 5m candle officially closes.
validLong = bullishSweep and inSession and barstate.isconfirmed
validShort = bearishSweep and inSession and barstate.isconfirmed
// =========================================================================
// 5. VISUALS & ALERTS
// =========================================================================
// Only print signals when the strict conditions are met
plotshape(validLong, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.normal, title="Valid Long")
plotshape(validShort, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.normal, title="Valid Short")
// Setup external alerts to fire ONLY on bar close
if validLong
alert("VALID LONG: Setup confirmed, candle closed, inside session.", alert.freq_once_per_bar_close)
if validShort
alert("VALID SHORT: Setup confirmed, candle closed, inside session.", alert.freq_once_per_bar_close)
// =========================================================================
// 6. DISCIPLINE DASHBOARD
// =========================================================================
// Keeps objective status directly on your screen
var table dash = table.new(position.top_right, 2, 2, border_width=1)
if barstate.islast
table.cell(dash, 0, 0, "Session Status", text_color=color.white, bgcolor=color.gray)
table.cell(dash, 1, 0, inSession ? "ACTIVE" : "NO TRADE ZONE", text_color=color.white, bgcolor=inSession ? color.green : color.red)
table.cell(dash, 0, 1, "Candle Status", text_color=color.white, bgcolor=color.gray)
table.cell(dash, 1, 1, barstate.isrealtime and not barstate.isconfirmed ? "WAIT FOR CLOSE" : "CLOSED", text_color=color.white, bgcolor=barstate.isrealtime and not barstate.isconfirmed ? color.orange : color.green)
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.