OPEN-SOURCE SCRIPT

Ultimate Lines Statistical Backtest @MaxMaserati

158
Ultimate lines (MAs/MACD/VWAP,DWA etc..) Statistical Backtest

This is a comprehensive statistical backtesting tool that allows traders to objectively measure the performance of 27+ different trading lines across multiple timeframes and sessions. Instead of guessing which moving averages, VWAPs, or volume levels actually work for your trading style, this indicator provides hard data showing exactly how price behaves around each line at specific times of day.
The indicator solves a critical problem: most lines create whipsaws in choppy markets, but knowing which lines have the highest continuation rates vs reversal rates at specific session times helps you avoid false signals and focus on setups with proven statistical edges.

🎯 LINES YOU CAN TEST
MMM Core Lines:

Mid MA: Trend velocity tracker using simple moving average
MMPD Line: Premium/Discount change-of-direction indicator
Fair Value Golden Ratio: 0.618 equilibrium level between premium and discount zones

Volume-Based Lines:

VWAP Daily/Weekly: Volume-weighted average price (daily and weekly sessions)
Volume POC Multi-TF: Multi-timeframe Point of Control (highest volume price level)
Volume POC Weekly: Weekly momentum pivot based on volume distribution

Range Midpoints:

Range Midpoint 50: 50-period high/low midpoint
Range Midpoint 14 TF1/TF2: Configurable timeframe range midpoints with smoothing options

Moving Averages (10 MA Types):

MACD Fast (12) / Signal (26): Standard MACD moving averages
Fast MA 20 / Mid MA 50 / Slow MA 200: Classic trend-following averages
Available MA Types: SMA, EMA, WMA, HMA, DEMA, TEMA, LSMA, KAMA, ALMA, VWMA

Volatility Indicators:

MVM Upper/Lower Bands: Momentum-based volatility bands with adaptive option
HVC Bullish/Bearish: High Volume Candle support/resistance levels

Ultimate Suite Advanced Lines:

DWAP (Delta Weighted Average Price): Directional volume-weighted price with upper/lower bands
HVN (High Volume Node): High-frequency trading node detection
Hybrid Line: Volume-weighted momentum composite
Trend Filter: Two-pole smoothing filter for trend clarity

STL Lines:

iBuSTL / iBeSTL: Internal Bullish/Bearish Structural Trend Liquidity levels


⚙️ HOW TO TEST

Select Lines: Check the boxes for lines you want to analyze (Mid MA, VWAP Daily, Volume POC, etc.)
Choose Times: Enable tracking for specific session times (default: 8:30 AM, 9:30 AM, 10:00 AM, Daily Close - EST)
Set Lookback: Choose how many days of historical data to analyze (default: 60 days)
Enable Pattern Analysis: Turn on "Enable Pattern Analysis" in settings
Wait for Data: The indicator needs 20 bars after each signal time to complete analysis
Review Statistics: Check the statistics table for detailed breakdowns


📈 STATISTICS EXPLAINED
For Each Tracked Time, You'll See:
🟢 Above Selected Lines (X samples):

Continued↑: Price stayed above the lines = bullish continuation
Reversed↓: Price broke below the lines = reversal/rejection

→Kept Going↓: After reversing down, price continued lower (bars 11-20)
→Stalled: After reversing down, price came back up (consolidation)


Neutral: Price didn't make a clear move either way

🔴 Below Selected Lines (X samples):

Continued↓: Price stayed below the lines = bearish continuation
Reversed↑: Price broke above the lines = reversal/support bounce

→Kept Going↑: After reversing up, price continued higher (bars 11-20)
→Stalled: After reversing up, price came back down (consolidation)


Neutral: No clear directional move

⭐ Star Ratings: Show which outcome happens most frequently (best probability)

🔬 HYBRID DETECTION SYSTEM (ADVANCED)
When enabled, the indicator uses a multi-signal composite scoring system that goes beyond simple percentage movements:
Signal A - % Movement Direction (40% weight):
Measures the strength and direction of price movement. Strong directional moves (>0.8%) score higher, while opposite-direction moves score negatively.
Signal B - Inside Candles (30% weight):
Detects true consolidation by counting how many candles close within a defined range. High inside-candle counts indicate choppy, stalled price action rather than clean continuation.
Signal C - Successive Closes (30% weight):
Tracks momentum persistence by counting consecutive closes in the expected direction. Long streaks (6+ bars) indicate strong follow-through, while breaks in the sequence suggest weakness.
Composite Score Classification:

⭐⭐⭐ Strong (75-100 points): All three signals align - high-confidence pattern
⭐⭐ Moderate (50-75 points): Two signals agree - reliable pattern
⭐ Weak (25-50 points): Mixed signals - lower confidence
⚠️ Strong Stalled (0-25 points): Signals show consolidation/reversal

This provides nuanced pattern detection that identifies not just IF a pattern succeeded, but HOW STRONGLY it performed.

💡 INTERPRETING RESULTS
Good Lines Show:

High continuation % when price is above/below (>60% is strong)
Clean "Kept Going" patterns after reversals (>50% indicates reliable rejection)
Low stalled % (less whipsaw/consolidation)
Consistent patterns across multiple times (validates the line's reliability)

Poor Lines Show:

50/50 continuation vs reversal (coin flip = no edge)
High stalled % (lots of whipsaw/false signals)
Inconsistent patterns across different times (unreliable)

Example Interpretation:
9:30 AM - VWAP Daily (120 samples)
🟢 Above:
Continued↑ 75 (62.5%) ⭐ BEST
Reversed↓ 30 (25.0%)
Meaning: When price is above VWAP Daily at 9:30 AM, it continues higher 62.5% of the time - this is a statistically strong bullish signal for that session time.

🎯 PRACTICAL VALUE
Solves the Whipsaw Problem:
Most moving averages and lines work beautifully in trending markets but create endless false signals in choppy, range-bound conditions. By analyzing specific session times and continuation vs reversal patterns, you can:

Identify high-probability setups: Focus on lines that show >60% continuation at your preferred trading times
Avoid weak signals: Skip lines with high stall rates or 50/50 outcomes
Time your entries better: Know which session times produce the cleanest patterns
Combine complementary lines: Stack multiple high-scoring lines for confluence
Adapt to market conditions: Switch to different lines when market structure changes

Real-World Application:
Instead of blindly trading VWAP crosses or MA bounces, you'll have objective data showing: "At 9:30 AM on ES, when price is above Mid MA + VWAP Daily + Volume POC, it continues higher 68% of the time with strong momentum (⭐⭐⭐)." This transforms discretionary guesswork into data-driven decision making.

⚙️ LINE DEFINITIONS
Moving Averages: Smooth price data over X periods to identify trend direction and dynamic support/resistance.
VWAP: Anchored average price weighted by volume - institutional traders' benchmark for "fair value."
Volume POC (Point of Control): Price level with the most traded volume - represents maximum market acceptance.
Fair Value Golden Ratio: Fibonacci 0.618 level between recent premium (high) and discount (low) - equilibrium zone.
DWAP (Delta Weighted): Price average weighted by buying vs selling volume delta - shows directional money flow.
Range Midpoints: Geometric center of recent high/low range - mean reversion pivot.
Volatility Bands: Envelope around momentum lines showing normal price deviation ranges.
HVN (High Volume Node): Automated detection of high-volume price clusters - institutional accumulation/distribution zones.

Note: This indicator is purely for statistical analysis and backtesting. It does not generate trade signals or provide entry/exit recommendations. Use the statistics to inform your own trading decisions and strategy development.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน