OPEN-SOURCE SCRIPT

Smart Pattern Scanner Pro

577
Smart Pattern Scanner Pro — Trainer’s Guide (Step-by-Step)

1) What this tool does
Smart Pattern Scanner Pro (SPS Pro) scans multiple timeframes at once for classic candlestick patterns, filters them by trend, and presents everything in a clean table with price, signal direction, volume context, a “Vol Strength” progress bar, and a human-friendly timestamp. It also composes a single alert message when one or more patterns are found on the latest bar close.
________________________________________
2) The table at a glance (how to read one row)
Each row = one timeframe (e.g., 5m, 15m, 1h, 4h, Daily, Weekly)
• Timeframe – Shown with a readable name (“5 Minutes”, “1 Hour”, “Daily”, etc.).
• Price – The latest close at the moment the pattern is confirmed on that timeframe.
• Pattern – The first qualifying pattern detected on the last confirmed bar of that timeframe (or “—” if none).
• Signal –
o 🟢 ▲ = Bullish
o 🔴 ▼ = Bearish
o 🔵 ◆ = Neutral (e.g., Doji/Spinning Top)
• Buy Vol / Sell Vol (optional) – A rough split of volume for the most recent closed candle on that timeframe (up-close volume vs. down-close volume).
• Vol Strength (optional) – A 10-block text bar showing Total Volume ÷ SMA(Volume); quick read:
o ~0–1.0: muted activity
o 1.0: above average
o 1.5: notably elevated
• Time – The end time of the bar in your selected Timezone (Exchange by default).
If a timeframe shows “—” under Pattern, it simply means no eligible pattern was confirmed on the last completed candle for that TF.
________________________________________
3) Inputs & customization (what each section controls)
📊 Table Settings
• Table Position – Choose where the table sits on the chart (Top/Middle/Bottom + Left/Center/Right).
• Table Size – Controls the text size for all table cells.
• Show Volume Analysis – Toggles Buy Vol / Sell Vol columns.
• Show Progress Indicators – Toggles the Vol Strength column.
• Timezone – Set to Exchange, or override it to view timestamps in your local preference.
🎨 Color Theme
• Bullish / Bearish / Neutral colors – Control signal and highlight accents.
• Volume Up / Volume Down colors – Control the colors of the volume numbers and the Vol Strength bar.
• Backgrounds, borders, and text use a professional dark palette for contrast and readability.
⏱️ Timeframes
• Timeframes (comma-separated) – e.g., 5,15,60,240,1D,1W
Valid entries: 1,3,5,15,30,60,120,240,480,720,1D/D,1W/W,1M/M,3M
The scanner will create one row per timeframe.
📈 Technical Analysis
• Detect Trend Based on SMA – If on, patterns are trend-qualified using an SMA gate:
o Uptrend (uTrd) = close > SMA(maLen)
o Downtrend (dTrd) = close < SMA(maLen)
• SMA Length (maLen) – Length for the trend SMA gate (default 50).
• Volume MA Length (volMaLen) – SMA length used to compute Vol Strength.
🕯️ Pattern Selection
• Pattern Type – Scan Bullish, Bearish, or Both.
• Checkboxes – Turn specific patterns on/off (Engulfing, Morning/Evening Stars, Three Soldiers/Crows, Doji family, Hammers, Tasuki Gaps, Windows, Harami, Piercing/Dark Cloud, etc.).
Tip: For faster performance, disable patterns you don’t use.
________________________________________
4) How detection actually works (under the hood)
1. Per-timeframe scanning
The script iterates through your list of timeframes. For each TF it calls the detection engine via request.security(…tf…, main(true)) so that the logic runs natively on that timeframe.
2. Trend qualifier (optional)
If Detect Trend Based on SMA is enabled:
o Bullish patterns often require the recent context to be at/after downtrend (e.g., a reversal) or during an uptrend depending on the pattern.
o Bearish patterns similarly check for uTrd/dTrd.
You’ll notice some checks use offsets like [1], [2], [4] to ensure the trend context existed before the current bar, making signals more realistic.
3. First-match wins
Inside each TF scan, patterns are checked in a fixed order. The code assigns the first eligible pattern to the row and ignores subsequent ones for that bar. This keeps rows clean and avoids double-signaling.
4. Confirmed bar only
The script saves a pattern only when the bar is confirmed (barstate.isconfirmed), reducing the “painting” of signals that vanish before close.
Important: For higher TFs, the table won’t update that TF’s row until its bar closes. E.g., a Daily pattern appears only after the daily candle closes.
5. Volume context
o BuyVol = TF volume if that TF bar closed up, else 0
o SellVol = TF volume if that TF bar closed down, else 0
o VolRatio = TF total volume ÷ SMA(volume, volMaLen)
That ratio feeds the Vol Strength bar for quick “is today active?” context.
6. Time formatting
The time shown is the end time of the TF bar, formatted to your Timezone input (Exchange by default). Intraday TFs show HH:mm; higher TFs show a clean date or time per your settings.
________________________________________
5) Alerts — how they’re built and how to use them
• On each bar close, SPS Pro assembles one multiline alert if any timeframe reported a pattern.
Example format:
• 🎯 Pattern Alert - NIFTY
• ├ 15: Engulfing (Bull) @ 24650.20
• ├ 60: Dark Cloud (Bear) @ 24580.90
• └─────────────
• To receive alerts in TradingView:
1. Add the indicator to your chart.
2. Click Create Alert.
3. In the Condition, choose “Any alert() function call” for this script.
4. Set “Once per bar close” (recommended, matches the script).
5. Choose your delivery channels and save.
________________________________________
6) Practical workflows (for new traders)
A) Intraday momentum trade (scalp/day trade)
1. Set TFs to 5,15,60.
2. Enable Engulfing, Hammer/Hanging Man, Morning/Evening Star, Shooting Star, Doji.
3. Keep Trend Based on SMA ON (SMA 50).
4. Wait for 5m + 15m to align in the same direction (both 🟢 or both 🔴).
5. Prefer entries when Vol Strength > 1.0 on the entry TF.
6. Place stop beyond the pattern’s invalidation (e.g., below Hammer low for long).
7. Scale out near prior intraday S/R; trail stops.
B) Swing reversal trade
1. Use higher TFs: 60,240,1D,1W.
2. Focus on Rising/Falling Three Methods, Morning/Evening (Doji) Stars, Three Soldiers/Crows.
3. Look for a fresh pattern on 4h or Daily, ideally with Vol Strength > 1.3.
4. Confirm confluence with structure (trendlines, weekly levels).
5. Plan wider stops and multi-day hold; review news/catalysts.
C) News avoidance & confirmation
• If Vol Strength spikes without a clean pattern, consider standing aside or waiting for the next bar to avoid whipsaw.
• When a pattern appears with a strong Vol Strength bar, it often signals attention-worthy activity—still validate with your own plan.
________________________________________
7) Best-practice interpretation tips
• Confluence beats single signals. Two TFs pointing the same way + decent Vol Strength is more reliable than a lone 5m signal.
• Neutral patterns (Doji/Spinning Top) are context markers, not trade triggers by themselves. Wait for follow-through.
• Trend gate matters. Keeping SMA gating ON reduces counter-trend noise.
• Bars must close. Remember: higher-TF rows only change after that TF bar closes.
• “First-match wins” means the order of checks matters. You can reorder or disable patterns to fit your style.
________________________________________
8) Performance & limits (TradingView realities)
• You’re scanning several TFs, running many pattern checks. Disable unused patterns or trim TFs if you hit resource limits.
• dynamic_requests=true helps, but extreme combinations (lots of TFs + all patterns + small chart TF) can still be heavy.
• If an exchange symbol’s volume behaves oddly, re-check Volume MA Length and your Timezone for clarity.
________________________________________
9) Common FAQs & troubleshooting
• “Why do I see ‘—’ on some rows?”
No qualifying pattern on the last closed bar of that TF, or your trend gate filtered it out.
• “Why are some signals late?”
Signals appear only on bar close (by design). That’s deliberate to avoid premature triggers.
• “My alert didn’t fire.”
Make sure the chart has an active alert set to “Any alert() function call” for this script and your alert frequency is Once per bar close.
• “Can I change the strength thresholds?”
Yes—edit the line that colors Vol Strength (currently >1.5 = stronger). Adjust to your preference.
• “I want more than one pattern per TF.”
This version stores one (the first match). You can adapt the logic to collect multiple, but keep the UI readable.
________________________________________
10) Suggested training exercises for new traders
1. Replay Mode drill – On a liquid symbol, step through 2 weeks of 5m/15m data. Log which SPS signals would you take/skip and why.
2. Confluence journal – Require at least two TFs aligned. Track outcomes for 20 trades.
3. Vol Strength filter – Only act when Vol Strength > 1.2. Compare results vs. no filter.
4. Pattern-specific week – Trade only Engulfing setups for one week (paper trading), then only Stars next week. Learn the nuances.
5. Risk practice – Fix risk at 0.5–1R per trade. Journal adherence to stops and take-profits.
________________________________________
11) Advanced customization ideas (optional)
• Re-order pattern checks to favor your preferred setups.
• Tighten/loosen trend gates (e.g., require uTrd[1] and uTrd around breakout patterns).
• Add a score column (e.g., +2 for multi-TF alignment, +1 for Vol Strength >1.3, −1 if Neutral on higher TF).
• Map “Body/Header/Title” text sizes to table sizes if you want more granular typography (current code uses the overall Table Size).
________________________________________
12) Strict disclaimer (aiTrendview)
aiTrendview Educational Notice & Risk Warning
• This scanner is provided strictly for education and research. It is not investment advice, a recommendation, or a solicitation to buy/sell any security, derivative, or cryptocurrency.
• Candlestick patterns and volume context are imperfect and can fail. Past performance does not guarantee future results.
• Markets involve substantial risk. You can lose more than your principal, especially with margin, options, or leveraged products.
• Signals are generated after bar close and may be delayed at higher timeframes or due to data/vendor issues.
• Always validate with your own analysis, risk management rules, and, where appropriate, consult a qualified financial advisor.
• By using this tool, you agree not to misuse it for unlawful activity, spam alerts, or to represent it as a guaranteed system. You accept full responsibility for any trades taken and outcomes incurred.
________________________________________
13) Quick setup checklist
• Add SPS Pro to your chart.
• Configure Timeframes you actually trade.
• Toggle Show Volume and Vol Strength as desired.
• Keep SMA Trend Gate ON for cleaner signals (tune maLen to your market).
• Create a TradingView alert for “Any alert() function call” → Once per bar close.
• Paper-trade a sample of signals before going live.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.