OPEN-SOURCE SCRIPT
Swing Stockpicking Dashboard

//version=5
indicator("Swing Stockpicking Dashboard (Mansfield RS + Trend Template)", overlay=true, max_labels_count=500)
// ---------- Inputs ----------
bench = input.symbol("SPY", "Benchmark (para RS)")
rsLen = input.int(252, "52w lookback (barras)", minval=20)
rsMaLen = input.int(252, "RS base MA (barras)", minval=20)
ma50Len = input.int(50, "SMA rápida", minval=1)
ma150Len = input.int(150, "SMA media", minval=1)
ma200Len = input.int(200, "SMA lenta", minval=1)
slopeLookback = input.int(22, "Pendiente MA200 (barras)", minval=1)
scoreThreshold = input.int(5, "Umbral score (0–7)", minval=0, maxval=7)
showMAs = input.bool(true, "Dibujar medias")
showTable = input.bool(true, "Mostrar tabla dashboard")
// ---------- Benchmark & Mansfield RS ----------
benchClose = request.security(bench, timeframe.period, close)
ratio = (benchClose > 0) ? (close / benchClose) : na
rsBase = ta.sma(ratio, rsMaLen)
mansfield = (rsBase != 0 and not na(rsBase)) ? ((ratio / rsBase - 1) * 100) : na
// ---------- Price MAs ----------
ma50 = ta.sma(close, ma50Len)
ma150 = ta.sma(close, ma150Len)
ma200 = ta.sma(close, ma200Len)
// ---------- 52w High/Low ----------
hi52 = ta.highest(high, rsLen)
lo52 = ta.lowest(low, rsLen)
// ---------- Minervini-style checks ----------
c1 = close > ma150 and close > ma200
c2 = ma150 > ma200
c3 = ma200 > ma200[slopeLookback] // MA200 subiendo vs hace ~1 mes (en D)
c4 = ma50 > ma150 and ma50 > ma200
c5 = close >= lo52 * 1.25 // ≥ +25% desde mínimo 52w
c6 = close >= hi52 * 0.75 // dentro del 25% de máximos 52w
c7 = (mansfield > 0) and (mansfield > mansfield[1]) // RS > 0 y mejorando
score = (c1 ? 1 : 0) + (c2 ? 1 : 0) + (c3 ? 1 : 0) + (c4 ? 1 : 0) + (c5 ? 1 : 0) + (c6 ? 1 : 0) + (c7 ? 1 : 0)
qualified = score >= scoreThreshold
// ---------- Plots ----------
if showMAs
plot(ma50, "SMA 50", linewidth=1)
plot(ma150, "SMA 150", linewidth=1)
plot(ma200, "SMA 200", linewidth=2)
plotshape(qualified, title="PICK", style=shape.triangleup, location=location.belowbar, size=size.tiny, text="PICK")
// ---------- Dashboard table ----------
var table t = table.new(position.top_right, 2, 9, frame_width=1)
f_row(_r, _name, _ok) =>
table.cell(t, 0, _r, _name)
table.cell(t, 1, _r, _ok ? "OK" : "—")
if showTable and barstate.islast
table.cell(t, 0, 0, "Check")
table.cell(t, 1, 0, "Pass")
f_row(1, "Price > SMA150 & SMA200", c1)
f_row(2, "SMA150 > SMA200", c2)
f_row(3, "SMA200 rising (" + str.tostring(slopeLookback) + ")", c3)
f_row(4, "SMA50 > SMA150 & SMA200", c4)
f_row(5, "≥ +25% from 52w low", c5)
f_row(6, "Within 25% of 52w high", c6)
f_row(7, "Mansfield RS > 0 & rising", c7)
table.cell(t, 0, 8, "Score")
table.cell(t, 1, 8, str.tostring(score) + "/7")
// ---------- Alerts ----------
alertcondition(qualified, "Qualified stock (PICK)", "El activo supera el score mínimo para stock-picking swing.")
indicator("Swing Stockpicking Dashboard (Mansfield RS + Trend Template)", overlay=true, max_labels_count=500)
// ---------- Inputs ----------
bench = input.symbol("SPY", "Benchmark (para RS)")
rsLen = input.int(252, "52w lookback (barras)", minval=20)
rsMaLen = input.int(252, "RS base MA (barras)", minval=20)
ma50Len = input.int(50, "SMA rápida", minval=1)
ma150Len = input.int(150, "SMA media", minval=1)
ma200Len = input.int(200, "SMA lenta", minval=1)
slopeLookback = input.int(22, "Pendiente MA200 (barras)", minval=1)
scoreThreshold = input.int(5, "Umbral score (0–7)", minval=0, maxval=7)
showMAs = input.bool(true, "Dibujar medias")
showTable = input.bool(true, "Mostrar tabla dashboard")
// ---------- Benchmark & Mansfield RS ----------
benchClose = request.security(bench, timeframe.period, close)
ratio = (benchClose > 0) ? (close / benchClose) : na
rsBase = ta.sma(ratio, rsMaLen)
mansfield = (rsBase != 0 and not na(rsBase)) ? ((ratio / rsBase - 1) * 100) : na
// ---------- Price MAs ----------
ma50 = ta.sma(close, ma50Len)
ma150 = ta.sma(close, ma150Len)
ma200 = ta.sma(close, ma200Len)
// ---------- 52w High/Low ----------
hi52 = ta.highest(high, rsLen)
lo52 = ta.lowest(low, rsLen)
// ---------- Minervini-style checks ----------
c1 = close > ma150 and close > ma200
c2 = ma150 > ma200
c3 = ma200 > ma200[slopeLookback] // MA200 subiendo vs hace ~1 mes (en D)
c4 = ma50 > ma150 and ma50 > ma200
c5 = close >= lo52 * 1.25 // ≥ +25% desde mínimo 52w
c6 = close >= hi52 * 0.75 // dentro del 25% de máximos 52w
c7 = (mansfield > 0) and (mansfield > mansfield[1]) // RS > 0 y mejorando
score = (c1 ? 1 : 0) + (c2 ? 1 : 0) + (c3 ? 1 : 0) + (c4 ? 1 : 0) + (c5 ? 1 : 0) + (c6 ? 1 : 0) + (c7 ? 1 : 0)
qualified = score >= scoreThreshold
// ---------- Plots ----------
if showMAs
plot(ma50, "SMA 50", linewidth=1)
plot(ma150, "SMA 150", linewidth=1)
plot(ma200, "SMA 200", linewidth=2)
plotshape(qualified, title="PICK", style=shape.triangleup, location=location.belowbar, size=size.tiny, text="PICK")
// ---------- Dashboard table ----------
var table t = table.new(position.top_right, 2, 9, frame_width=1)
f_row(_r, _name, _ok) =>
table.cell(t, 0, _r, _name)
table.cell(t, 1, _r, _ok ? "OK" : "—")
if showTable and barstate.islast
table.cell(t, 0, 0, "Check")
table.cell(t, 1, 0, "Pass")
f_row(1, "Price > SMA150 & SMA200", c1)
f_row(2, "SMA150 > SMA200", c2)
f_row(3, "SMA200 rising (" + str.tostring(slopeLookback) + ")", c3)
f_row(4, "SMA50 > SMA150 & SMA200", c4)
f_row(5, "≥ +25% from 52w low", c5)
f_row(6, "Within 25% of 52w high", c6)
f_row(7, "Mansfield RS > 0 & rising", c7)
table.cell(t, 0, 8, "Score")
table.cell(t, 1, 8, str.tostring(score) + "/7")
// ---------- Alerts ----------
alertcondition(qualified, "Qualified stock (PICK)", "El activo supera el score mínimo para stock-picking swing.")
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.