本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("ICT EXECUTION GUARD", shorttitle="ICT GUARD", overlay=true)
// ============================================================================
// 1. INPUT SETTINGS
// ============================================================================
grpChecklist = "01. Directional Bias & SOP Checklist"
biasInput = input.string("NEUTRAL", "01. Market Bias", options=["BULLISH", "BEARISH", "NEUTRAL"], group=grpChecklist)
sop02Input = input.bool(false, "02. Framework / Narrative", group=grpChecklist)
sop03Input = input.bool(false, "03. Hit POI (HTF)", group=grpChecklist)
sop04Input = input.bool(false, "04. Swing Formation HTF", group=grpChecklist)
sop05Input = input.bool(false, "05. EQ validation & POI MTF", group=grpChecklist)
sop06Input = input.bool(false, "06. Swing Formation MTF", group=grpChecklist)
sop07Input = input.bool(false, "07. Clear Target", group=grpChecklist)
sop08Input = input.bool(false, "08. CISD (LTF)", group=grpChecklist)
grpDiscipline = "02. Discipline & Reset Control"
chasingInput = input.bool(false, "Market Moving Without Confirmation (FOMO Guard)", tooltip="Aktifkan jika harga bergerak impulsif tanpa konfirmasi lengkap untuk memicu peringatan DO NOT CHASE THE MARKET.", group=grpDiscipline)
resetAllInput = input.bool(false, "RESET ALL SOP (Force Pending)", tooltip="Mengunci dan mengembalikan seluruh status checklist ke Pending. Untuk mengosongkan centang input secara permanen, gunakan menu Settings > Defaults > Reset Settings.", group=grpDiscipline)
grpVisual = "03. Dashboard Appearance"
posInput = input.string("Top Right", "Dashboard Position", options=["Top Left", "Top Center", "Top Right", "Middle Left", "Middle Center", "Middle Right", "Bottom Left", "Bottom Center", "Bottom Right"], group=grpVisual)
sizeInput = input.string("Normal", "Dashboard Size", options=["Compact", "Normal", "Large"], group=grpVisual)
bgTransp = input.int(20, "Background Transparency (%)", minval=0, maxval=85, step=5, tooltip="Atur tingkat transparansi background grey muda dashboard (0 = solid, 85 = sangat transparan).", group=grpVisual)
// ============================================================================
// 2. LIGHT GREY TRANSPARENT & HIGH-CONTRAST COLOR PALETTE
// ============================================================================
colBgPrimary = color.new(#D5DAE2, bgTransp) // Light Cool Grey (Header & Frame Utama)
colBgRow = color.new(#E6E9EF, bgTransp) // Soft Light Grey (Baris SOP Checklist)
colBgAlt = color.new(#C7CED9, bgTransp) // Silver Grey (Sub-header Bias)
colBorder = color.new(#94A3B8, 15) // Garis Pembatas Slate Grey
colGold = #784F00 // Deep Bronze Gold (Kontras tajam di atas grey muda)
colGoldSubtle = color.new(#9A6700, 15) // Frame Luar Bronze Gold
colEmerald = #047857 // Deep Emerald Green (Teks Completed & Bullish)
colEmeraldTxt = #064E3B // Dark Forest Emerald (Teks Gate Unlocked)
colEmeraldBg = color.new(#A7F3D0, 15) // Soft Mint Emerald Transparan
colTextDark = #0F172A // Deep Charcoal / Near Black (Teks Utama)
colTextMuted = #334155 // Dark Slate (Teks SOP Pending agar tetap jelas)
colTextBadge = #475569 // Medium-Dark Slate (Badge PENDING & Lock)
colCrimson = #B91C1C // Deep Crimson Red (Bearish & Locked)
colCrimsonTxt = #991B1B // Dark Crimson (Teks Gate Locked & FOMO)
colCrimsonBg = color.new(#FECACA, 15) // Soft Rose Crimson Transparan
colAmberTxt = #92400E // Deep Amber Brown (Teks Peringatan)
colAmberBg = color.new(#FDE68A, 15) // Soft Warm Amber Transparan
// ============================================================================
// 3. SOP & STRICT TRADE GATE LOGIC
// ============================================================================
effectiveBias = resetAllInput ? "NEUTRAL" : biasInput
sop01Done = not resetAllInput and (effectiveBias == "BULLISH" or effectiveBias == "BEARISH")
sop02Done = not resetAllInput and sop02Input
sop03Done = not resetAllInput and sop03Input
sop04Done = not resetAllInput and sop04Input
sop05Done = not resetAllInput and sop05Input
sop06Done = not resetAllInput and sop06Input
sop07Done = not resetAllInput and sop07Input
sop08Done = not resetAllInput and sop08Input
completedCount = (sop01Done ? 1 : 0) + (sop02Done ? 1 : 0) + (sop03Done ? 1 : 0) + (sop04Done ? 1 : 0) +
(sop05Done ? 1 : 0) + (sop06Done ? 1 : 0) + (sop07Done ? 1 : 0) + (sop08Done ? 1 : 0)
progressPct = int(math.round((completedCount / 8.0) * 100))
isTradeUnlocked = sop01Done and sop02Done and sop03Done and sop04Done and sop05Done and sop06Done and sop07Done and sop08Done
// Directional Execution Status
isBuyActive = isTradeUnlocked and effectiveBias == "BULLISH"
isSellActive = isTradeUnlocked and effectiveBias == "BEARISH"
// Discipline Warning System
var string warningMsg = ""
var color warningTextCol = colTextDark
var color warningBgCol = colBgAlt
if effectiveBias == "NEUTRAL"
warningMsg := "NO CLEAR DIRECTION"
warningTextCol := colTextDark
warningBgCol := colBgAlt
else if chasingInput and not isTradeUnlocked
warningMsg := "DO NOT CHASE THE MARKET"
warningTextCol := colCrimsonTxt
warningBgCol := colCrimsonBg
else if not isTradeUnlocked
warningMsg := "WAIT FOR YOUR SETUP"
warningTextCol := colAmberTxt
warningBgCol := colAmberBg
else if effectiveBias == "BULLISH"
warningMsg := "YOUR SETUP IS VALID • BUY SETUP READY"
warningTextCol := colEmeraldTxt
warningBgCol := colEmeraldBg
else
warningMsg := "YOUR SETUP IS VALID • SELL SETUP READY"
warningTextCol := colEmeraldTxt
warningBgCol := colEmeraldBg
// ============================================================================
// 4. LAYOUT & TABLE INITIALIZATION
// ============================================================================
tablePos = switch posInput
"Top Left" => position.top_left
"Top Center" => position.top_center
"Top Right" => position.top_right
"Middle Left" => position.middle_left
"Middle Center" => position.middle_center
"Middle Right" => position.middle_right
"Bottom Left" => position.bottom_left
"Bottom Center" => position.bottom_center
=> position.bottom_right
headerSize = switch sizeInput
"Compact" => size.small
"Normal" => size.normal
=> size.large
bodySize = switch sizeInput
"Compact" => size.tiny
"Normal" => size.small
=> size.normal
var table dash = table.new(tablePos, 2, 15, bgcolor=colBgPrimary, border_color=colBorder, border_width=1, frame_color=colGoldSubtle, frame_width=1)
if barstate.isfirst
table.merge_cells(dash, 0, 0, 1, 0)
table.merge_cells(dash, 0, 3, 1, 3)
table.merge_cells(dash, 0, 12, 1, 12)
table.merge_cells(dash, 0, 14, 1, 14)
f_renderSopRow(int rowIdx, string sopLabel, bool isDone, string txtSize) =>
prefix = isDone ? "✓ " : "○ "
statusTxt = isDone ? "DONE" : "PENDING"
txtCol = isDone ? colEmerald : colTextMuted
badgeCol = isDone ? colEmerald : colTextBadge
table.cell(dash, 0, rowIdx, prefix + sopLabel, text_color=txtCol, bgcolor=colBgRow, text_size=txtSize, text_halign=text.align_left)
table.cell(dash, 1, rowIdx, statusTxt, text_color=badgeCol, bgcolor=colBgRow, text_size=txtSize, text_halign=text.align_right)
// ============================================================================
// 5. DASHBOARD RENDERING (LIGHTWEIGHT ON LAST BAR)
// ============================================================================
if barstate.islast
// 1. Product Header
headerText = resetAllInput ? "ICT EXECUTION GUARD [RESET]\nBy Tompuu" : "ICT EXECUTION GUARD\nBy Tompuu"
table.cell(dash, 0, 0, headerText, text_color=colGold, bgcolor=colBgPrimary, text_size=headerSize, text_halign=text.align_center)
// 2. Market Bias
biasColor = effectiveBias == "BULLISH" ? colEmerald : effectiveBias == "BEARISH" ? colCrimson : colTextDark
table.cell(dash, 0, 1, "MARKET BIAS", text_color=colTextDark, bgcolor=colBgAlt, text_size=bodySize, text_halign=text.align_left)
table.cell(dash, 1, 1, effectiveBias, text_color=biasColor, bgcolor=colBgAlt, text_size=bodySize, text_halign=text.align_right)
// 3. SOP Progress
progTextColor = isTradeUnlocked ? colEmerald : colTextDark
table.cell(dash, 0, 2, "SOP PROGRESS", text_color=colTextDark, bgcolor=colBgRow, text_size=bodySize, text_halign=text.align_left)
table.cell(dash, 1, 2, str.tostring(completedCount) + " / 8", text_color=progTextColor, bgcolor=colBgRow, text_size=bodySize, text_halign=text.align_right)
// 4. Progress Bar (20 Blocks)
totalBlocks = 20
filledBlocks = int(math.round((completedCount / 8.0) * totalBlocks))
barStr = ""
for i = 0 to totalBlocks - 1
barStr += (i < filledBlocks ? "█" : "░")
barDisplay = barStr + " " + str.tostring(progressPct) + "%"
barColor = isTradeUnlocked ? colEmerald : completedCount > 0 ? colGold : colTextBadge
table.cell(dash, 0, 3, barDisplay, text_color=barColor, bgcolor=colBgPrimary, text_size=bodySize, text_halign=text.align_center)
// 5. Eight SOP Checklist
f_renderSopRow(4, "01 BIAS", sop01Done, bodySize)
f_renderSopRow(5, "02 FRAMEWORK / NARRATIVE", sop02Done, bodySize)
f_renderSopRow(6, "03 HIT POI (HTF)", sop03Done, bodySize)
f_renderSopRow(7, "04 SWING FORMATION HTF", sop04Done, bodySize)
f_renderSopRow(8, "05 EQ VALIDATION & POI MTF", sop05Done, bodySize)
f_renderSopRow(9, "06 SWING FORMATION MTF", sop06Done, bodySize)
f_renderSopRow(10, "07 CLEAR TARGET", sop07Done, bodySize)
f_renderSopRow(11, "08 CISD (LTF)", sop08Done, bodySize)
// 6. Trade Gate Status
gateText = isTradeUnlocked ? "TRADE UNLOCKED\nALL SOP COMPLETED" : "TRADE LOCKED\nWAIT FOR YOUR SETUP"
gateTxtCol = isTradeUnlocked ? colEmeraldTxt : colCrimsonTxt
gateBgCol = isTradeUnlocked ? colEmeraldBg : colCrimsonBg
table.cell(dash, 0, 12, gateText, text_color=gateTxtCol, bgcolor=gateBgCol, text_size=headerSize, text_halign=text.align_center)
// 7. Directional Status
buyTxt = isBuyActive ? "● BUY ACTIVE" : "✕ BUY LOCKED"
sellTxt = isSellActive ? "● SELL ACTIVE" : "✕ SELL LOCKED"
buyCol = isBuyActive ? colEmerald : colTextBadge
sellCol = isSellActive ? colEmerald : colTextBadge
table.cell(dash, 0, 13, buyTxt, text_color=buyCol, bgcolor=colBgPrimary, text_size=bodySize, text_halign=text.align_center)
table.cell(dash, 1, 13, sellTxt, text_color=sellCol, bgcolor=colBgPrimary, text_size=bodySize, text_halign=text.align_center)
// 8. Discipline Warning
table.cell(dash, 0, 14, warningMsg, text_color=warningTextCol, bgcolor=warningBgCol, text_size=bodySize, text_halign=text.align_center)