本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("SHARIIF Trading MODEL | ", overlay=true)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 1. DASHBOARD CUSTOMIZATION
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
groupDisplay = "01 | DASHBOARD DESIGN"
theme = input.string("Black", "Color Theme", options=["Black", "Dark", "White"], group=groupDisplay)
dashboardSize = input.string("Small", "Dashboard Size", options=["Tiny", "Small", "Normal", "Large"], group=groupDisplay)
dashboardPosition = input.string("Top Right", "Dashboard Position", options=["Top Right", "Top Left", "Top Center", "Middle Right", "Middle Left", "Middle Center", "Bottom Right", "Bottom Left", "Bottom Center"], group=groupDisplay)
transparency = input.int(10, "Background Transparency", minval=0, maxval=100, group=groupDisplay)
accentColor = input.color(color.rgb(0, 190, 150), "Accent Color", group=groupDisplay)
showPhase = input.bool(true, "Show Trading Phase", group=groupDisplay)
showScore = input.bool(true, "Show Score", group=groupDisplay)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 2. TRADING PHASE
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
groupPhase = "02 | TRADING PHASE"
tradingPhase = input.string("PRE-TRADE", "Current Phase", options=["PRE-TRADE", "IN TRADE", "POST-TRADE"], group=groupPhase)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 3. SHARIIF MODEL CHECKLIST
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
groupChecklist = "03 | MODEL CHECKLIST"
rule1 = input.bool(false, "HTFM CCI & RSI Divergence", group=groupChecklist)
rule2 = input.bool(false, "SMT / LQ", group=groupChecklist)
rule3 = input.bool(false, "CCI & RSI SMT", group=groupChecklist)
rule4 = input.bool(false, "Purge Time", group=groupChecklist)
rule5 = input.bool(false, "M# 1", group=groupChecklist)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 4. SCORE CALCULATION
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
score = (rule1 ? 1 : 0) + (rule2 ? 1 : 0) + (rule3 ? 1 : 0) + (rule4 ? 1 : 0) + (rule5 ? 1 : 0)
firstThree = rule1 and rule2 and rule3
allFive = firstThree and rule4 and rule5
tradeStatus = not firstThree ? "NO TRADE" : allFive ? "HIGH PROBABILITY" : "POOR"
statusColor = not firstThree ? color.rgb(220, 65, 65) : allFive ? color.rgb(0, 190, 120) : color.rgb(230, 165, 40)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 5. TEXT SIZE
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
textSize = switch dashboardSize
"Tiny" => size.tiny
"Small" => size.small
"Normal" => size.normal
"Large" => size.large
=> size.small
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 6. DASHBOARD POSITION
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
tablePosition = switch dashboardPosition
"Top Right" => position.top_right
"Top Left" => position.top_left
"Top Center" => position.top_center
"Middle Right" => position.middle_right
"Middle Left" => position.middle_left
"Middle Center" => position.middle_center
"Bottom Right" => position.bottom_right
"Bottom Left" => position.bottom_left
"Bottom Center" => position.bottom_center
=> position.top_right
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 7. COLOR THEMES
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
backgroundColor = theme == "Black" ? color.rgb(12, 12, 12) : theme == "Dark" ? color.rgb(30, 35, 43) : color.rgb(245, 245, 245)
textColor = theme == "White" ? color.rgb(25, 25, 25) : color.rgb(240, 240, 240)
mutedColor = theme == "White" ? color.rgb(100, 100, 100) : color.rgb(165, 175, 185)
panelColor = color.new(backgroundColor, transparency)
headerColor = color.new(accentColor, 15)
borderColor = color.new(mutedColor, 75)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 8. CHECKBOX SYMBOLS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
check1 = rule1 ? "✅" : "☐"
check2 = rule2 ? "✅" : "☐"
check3 = rule3 ? "✅" : "☐"
check4 = rule4 ? "✅" : "☐"
check5 = rule5 ? "✅" : "☐"
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 9. CREATE DASHBOARD
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
var table dashboard = table.new(tablePosition, 1, 9, bgcolor=panelColor, frame_color=borderColor, frame_width=1, border_color=borderColor, border_width=0)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 10. DISPLAY DASHBOARD
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
if barstate.islast
// TITLE
table.cell(dashboard, 0, 0, "SHARIIF MODEL", text_color=color.white, bgcolor=headerColor, text_size=textSize, text_halign=text.align_center)
// PHASE
if showPhase
table.cell(dashboard, 0, 1, "PHASE | " + tradingPhase, text_color=accentColor, bgcolor=panelColor, text_size=textSize, text_halign=text.align_left)
else
table.cell(dashboard, 0, 1, "", bgcolor=panelColor)
// CHECKLIST
table.cell(dashboard, 0, 2, check1 + " HTFM CCI & RSI Divergence", text_color=textColor, bgcolor=panelColor, text_size=textSize, text_halign=text.align_left)
table.cell(dashboard, 0, 3, check2 + " SMT / LQ", text_color=textColor, bgcolor=panelColor, text_size=textSize, text_halign=text.align_left)
table.cell(dashboard, 0, 4, check3 + " CCI & RSI SMT", text_color=textColor, bgcolor=panelColor, text_size=textSize, text_halign=text.align_left)
table.cell(dashboard, 0, 5, check4 + " Purge Time", text_color=textColor, bgcolor=panelColor, text_size=textSize, text_halign=text.align_left)
table.cell(dashboard, 0, 6, check5 + " M# 1", text_color=textColor, bgcolor=panelColor, text_size=textSize, text_halign=text.align_left)
// SCORE
if showScore
table.cell(dashboard, 0, 7, "SCORE | " + str.tostring(score) + " / 5", text_color=accentColor, bgcolor=panelColor, text_size=textSize, text_halign=text.align_left)
else
table.cell(dashboard, 0, 7, "", bgcolor=panelColor)
// FINAL TRADE STATUS
table.cell(dashboard, 0, 8, "STATUS | " + tradeStatus, text_color=color.white, bgcolor=color.new(statusColor, 15), text_size=textSize, text_halign=text.align_left)