Penny Stock ORB Pro - Dual Score

TreyThaTrader · study · 298 行 · 点赞 12 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=6
indicator("Penny Stock ORB Pro - Dual Score", overlay=true)
 
// ==========================================
// 1. ATR SETTINGS
// ==========================================
 
grpATR = "ATR Settings"
 
atrLength = input.int(14, "ATR Length", group=grpATR)
atrBaseLength = input.int(20, "ATR Baseline Length", group=grpATR)
 
minATR = input.float(0.5, "Minimum ATR %", step=0.1, group=grpATR)
maxATR = input.float(2.5, "Maximum ATR %", step=0.1, group=grpATR)
 
minExpansion = input.float(1.1, "Minimum ATR Expansion", step=0.1, group=grpATR)
maxExpansion = input.float(2.0, "Maximum ATR Expansion", step=0.1, group=grpATR)
 
// ==========================================
// 2. VOLUME SETTINGS
// ==========================================
 
grpVol = "Volume Settings"
 
min5mVolume = input.int(15000, "Minimum 5m Volume", group=grpVol)
minRVOL = input.float(1.5, "Minimum RVOL", step=0.1, group=grpVol)
rvolLength = input.int(20, "RVOL Average Length", group=grpVol)
 
breakoutMultiplier = input.float(1.5, "Breakout Volume Multiplier", step=0.1, group=grpVol)
breakoutLength = input.int(10, "Breakout Volume Lookback", group=grpVol)
 
// ==========================================
// 3. LIQUIDITY SETTINGS
// ==========================================
 
grpLiq = "Liquidity Settings"
 
minDailyVolume = input.int(500000, "Minimum Average Daily Volume", group=grpLiq)
min5mDollar = input.float(100000, "Minimum 5m Dollar Volume", group=grpLiq)
minDailyDollar = input.float(2000000, "Minimum Average Daily Dollar Volume", group=grpLiq)
 
// ==========================================
// 4. PRICE SETTINGS
// ==========================================
 
grpPrice = "Price Settings"
 
minPrice = input.float(2.0, "Minimum Price", group=grpPrice)
maxPrice = input.float(10.0, "Maximum Price", group=grpPrice)
 
// ==========================================
// 5. SCORE THRESHOLDS
// ==========================================
 
grpScore = "Score Thresholds"
 
earlyThreshold = input.int(70, "Early Momentum Alert Score", minval=0, maxval=100, group=grpScore)
entryThreshold = input.int(80, "ORB Entry Alert Score", minval=0, maxval=100, group=grpScore)
 
// ==========================================
// 6. FILTER CONTROLS
// ==========================================
 
grpControls = "Filter Controls"
 
require5m = input.bool(true, "Require 5m Chart", group=grpControls)
 
// ==========================================
// 7. ATR CALCULATIONS
// ==========================================
 
atr = ta.atr(atrLength)
atrBase = ta.sma(atr, atrBaseLength)
 
atrPct = close > 0 ? atr / close * 100 : na
atrExpansion = atrBase > 0 ? atr / atrBase : na
 
atrPass = atrPct >= minATR and atrPct <= maxATR
expansionPass = atrExpansion >= minExpansion and atrExpansion <= maxExpansion
 
// ==========================================
// 8. VOLUME CALCULATIONS
// ==========================================
 
avgVol = ta.sma(volume, rvolLength)
rvol = avgVol > 0 ? volume / avgVol : na
 
volumePass = volume >= min5mVolume
rvolPass = rvol >= minRVOL
 
previousAvgVol = ta.sma(volume[1], breakoutLength)
 
breakoutVolPass = previousAvgVol > 0 and volume >= previousAvgVol * breakoutMultiplier
 
// ==========================================
// 9. DAILY LIQUIDITY
// ==========================================
 
avgDailyVol = request.security(
     syminfo.tickerid, "D",
     ta.sma(volume, 20),
     lookahead=barmerge.lookahead_off)
 
avgDailyDollar = request.security(
     syminfo.tickerid, "D",
     ta.sma(close * volume, 20),
     lookahead=barmerge.lookahead_off)
 
dailyVolumePass = avgDailyVol >= minDailyVolume
dailyDollarPass = avgDailyDollar >= minDailyDollar
 
fiveMinuteDollar = close * volume
fiveMinuteDollarPass = fiveMinuteDollar >= min5mDollar
 
// ==========================================
// 10. PRICE FILTER
// ==========================================
 
pricePass = close >= minPrice and close <= maxPrice
 
// ==========================================
// 11. TIMEFRAME
// ==========================================
 
is5m = timeframe.isminutes and timeframe.multiplier == 5
timeframePass = not require5m or is5m
 
// ==========================================
// 12. EARLY MOMENTUM SCORE
// ==========================================
 
earlyScore =
     (rvolPass ? 25 : 0) +
     (expansionPass ? 20 : 0) +
     (volumePass ? 15 : 0) +
     (atrPass ? 15 : 0) +
     (dailyDollarPass ? 15 : 0) +
     (pricePass ? 10 : 0)
 
earlyQualified = timeframePass and earlyScore >= earlyThreshold
 
// ==========================================
// 13. OPENING RANGE BREAKOUT
// ==========================================
 
orbSession = input.session("0930-0945", "Opening Range", group="ORB Settings")
tradeSession = input.session("0945-1600", "ORB Trading Session", group="ORB Settings")
 
inORB = not na(time(timeframe.period, orbSession, "America/New_York"))
afterORB = not na(time(timeframe.period, tradeSession, "America/New_York"))
 
newDay = ta.change(time("D")) != 0
 
var float orbHigh = na
var float orbLow = na
 
if newDay
    orbHigh := na
    orbLow := na
 
if inORB
    orbHigh := na(orbHigh) ? high : math.max(orbHigh, high)
    orbLow := na(orbLow) ? low : math.min(orbLow, low)
 
orbReady = afterORB and not na(orbHigh) and not na(orbLow)
 
orbBreakout = orbReady and close > orbHigh
 
// ==========================================
// 14. VWAP CONFIRMATION
// ==========================================
 
vwapValue = ta.vwap(hlc3)
vwapPass = close > vwapValue
 
// ==========================================
// 15. ENTRY CONFIRMATION SCORE
// ==========================================
 
entryScore =
     (orbBreakout ? 35 : 0) +
     (vwapPass ? 25 : 0) +
     (breakoutVolPass ? 20 : 0) +
     (rvolPass ? 10 : 0) +
     (expansionPass ? 10 : 0)
 
entryQualified = timeframePass and entryScore >= entryThreshold and orbReady
 
// ==========================================
// 16. SCORE CLASSIFICATIONS
// ==========================================
 
f_rating(int score) =>
    score >= 85 ? "EXCELLENT" :
     score >= 70 ? "STRONG" :
     score >= 50 ? "DEVELOPING" : "WEAK"
 
f_color(int score) =>
    score >= 85 ? color.lime :
     score >= 70 ? color.green :
     score >= 50 ? color.orange : color.red
 
// ==========================================
// 17. CHART PLOTS
// ==========================================
 
plot(orbReady or inORB ? orbHigh : na, "ORB High", color=color.lime, linewidth=2, style=plot.style_linebr)
plot(orbReady or inORB ? orbLow : na, "ORB Low", color=color.red, linewidth=2, style=plot.style_linebr)
 
plot(vwapValue, "VWAP", color=color.orange, linewidth=2)
 
plotshape(
     earlyQualified and not earlyQualified[1],
     title="Early Momentum",
     style=shape.circle,
     location=location.belowbar,
     color=color.orange,
     size=size.tiny,
     text="EARLY")
 
plotshape(
     entryQualified and not entryQualified[1],
     title="ORB Confirmed",
     style=shape.labelup,
     location=location.belowbar,
     color=color.lime,
     text="ORB",
     textcolor=color.black)
 
// ==========================================
// 18. DASHBOARD
// ONLY LEFT CATEGORY LABELS CHANGED TO WHITE
// ==========================================
 
var table dash = table.new(
     position.top_right, 2, 12,
     bgcolor=color.new(color.black, 10),
     border_width=1,
     border_color=color.gray)
 
if barstate.islast
    table.cell(dash, 0, 0, "PENNY STOCK ORB", bgcolor=color.navy, text_color=color.white)
    table.cell(dash, 1, 0, "SCORE", bgcolor=color.navy, text_color=color.white)
 
    table.cell(dash, 0, 1, "EARLY MOMENTUM", text_color=color.white)
    table.cell(dash, 1, 1, str.tostring(earlyScore) + "/100", text_color=f_color(earlyScore))
 
    table.cell(dash, 0, 2, "Early Status", text_color=color.white)
    table.cell(dash, 1, 2, f_rating(earlyScore), text_color=f_color(earlyScore))
 
    table.cell(dash, 0, 3, "RVOL", text_color=color.white)
    table.cell(dash, 1, 3, str.tostring(rvol, "#.##") + "x", text_color=rvolPass ? color.lime : color.red)
 
    table.cell(dash, 0, 4, "ATR %", text_color=color.white)
    table.cell(dash, 1, 4, str.tostring(atrPct, "#.##") + "%", text_color=atrPass ? color.lime : color.red)
 
    table.cell(dash, 0, 5, "ATR Expansion", text_color=color.white)
    table.cell(dash, 1, 5, str.tostring(atrExpansion, "#.##") + "x", text_color=expansionPass ? color.lime : color.red)
 
    table.cell(dash, 0, 6, "ORB ENTRY SCORE", text_color=color.white)
    table.cell(dash, 1, 6, str.tostring(entryScore) + "/100", text_color=f_color(entryScore))
 
    table.cell(dash, 0, 7, "ORB Breakout", text_color=color.white)
    table.cell(dash, 1, 7, orbBreakout ? "CONFIRMED" : "WAITING", text_color=orbBreakout ? color.lime : color.orange)
 
    table.cell(dash, 0, 8, "VWAP Alignment", text_color=color.white)
    table.cell(dash, 1, 8, vwapPass ? "PASS" : "FAIL", text_color=vwapPass ? color.lime : color.red)
 
    table.cell(dash, 0, 9, "Breakout Volume", text_color=color.white)
    table.cell(dash, 1, 9, breakoutVolPass ? "PASS" : "FAIL", text_color=breakoutVolPass ? color.lime : color.red)
 
    table.cell(dash, 0, 10, "Entry Status", text_color=color.white)
    table.cell(dash, 1, 10, entryQualified ? "CONFIRMED" : "NOT READY",
         bgcolor=entryQualified ? color.new(color.green, 15) : color.new(color.red, 25),
         text_color=color.white)
 
    table.cell(dash, 0, 11, "Timeframe", text_color=color.white)
    table.cell(dash, 1, 11, is5m ? "5 MIN" : "CHANGE TO 5M",
         text_color=is5m ? color.lime : color.red)
 
// ==========================================
// 19. ALERTS
// ==========================================
 
alertcondition(
     earlyQualified and not earlyQualified[1],
     title="Early Momentum Detected",
     message="Early momentum detected on {{ticker}}. Check the ORB dashboard.")
 
alertcondition(
     entryQualified and not entryQualified[1],
     title="ORB Entry Confirmed",
     message="ORB entry conditions confirmed on {{ticker}}. Check chart and risk.")
 
alertcondition(
     entryQualified,
     title="ORB Qualified - Every Bar",
     message="ORB conditions remain qualified on {{ticker}}.")

← 返回列表