Jump to content

Alpha Research: Difference between revisions

From PlusEV Wiki Page
No edit summary
No edit summary
Line 26: Line 26:


<div style="background:#e6f3ff; border:1px solid #3399ff; padding:10px; margin:10px 0;">
<div style="background:#e6f3ff; border:1px solid #3399ff; padding:10px; margin:10px 0;">
'''Note:''' 1-Minute data exists in the dataset but is NOT currently used for entry precision.</div>
'''Note:''' 1-Minute data exists in dataset but is NOT currently used for entry precision.</div>


== Backtest Results Summary ==
== Backtest Results Summary ==

Revision as of 16:32, 5 January 2026

Multi_Timeframe Dynamic Trend Reversion (MTF_DTR)


PART 1: STRATEGY OVERVIEW

What Is This Strategy?

Multi_Timeframe Dynamic Trend Reversion (MTF_DTR) - A systematic intraday trading strategy that enters when price pulls back to 21-period Moving Average during established trends.

Timeframes Used

Timeframe Purpose
5-Minute Entry timeframe - signals and trade execution
15-Minute Confirmation timeframe
1-Hour Primary timeframe for trend analysis
4-Hour Higher timeframe context (MTF)
Daily Context timeframe for overall direction
Note: 1-Minute data exists in dataset but is NOT currently used for entry precision.

Backtest Results Summary

Metric Value
Period 19 months
Total Trades 7,534
Win Rate 57.6%
Profit Factor 1.20
Initial Capital Rs 1.00 Lakhs
Final Value Rs 26.48 Lakhs
Total Return 2,548%
Max Drawdown -78.6%

PART 2: THE EDGE (Core Concept)

The Big Idea

Trade pullbacks to the 21-period Moving Average (MA21) during established trends.

When the market is trending, price naturally pulls back to the 21 MA before continuing. We enter at these pullback zones, trading WITH the trend direction.

Why It Works

  1. Mean Reversion - Price tends to return to the average after moving away
  2. Trend Following - We only trade in the direction of the trend
  3. Value Entry - Entering on pullbacks gives better risk:reward
  4. Institutional Behavior - Big players accumulate at MA zones

The "MA is a ZONE" Principle

"The MA is a ZONE, not a thin line"

Entry is allowed within ±25 points of MA21, not just at the exact MA value.

Why ±25 points?

  • Price rarely touches MA exactly
  • Gives room for entry without chasing
  • Accounts for spread and slippage
  • MCX Crude typical range: 50-100 pts/day

PART 3: DIRECTION DETERMINATION (The Foundation)

THIS IS THE MOST IMPORTANT RULE

The MA21 slope determines the ONLY direction you can trade. This is a HARD FILTER - no exceptions.

MA21 Slope = Trade Direction

MA21 Slope Allowed Direction Logic
Rising (↗) LONG only Trade with uptrend, never short
Declining (↘) SHORT only Trade with downtrend, never long
Flat (→) Use MTF direction Let higher timeframes decide

How Slope Is Calculated

Slope Value Classification Threshold
> +0.01% RISING Bullish - LONG only
< -0.01% DECLINING Bearish - SHORT only
Between ±0.01% FLAT Use MTF consensus

Why 80% of Trades Were SHORT

In our 19-month backtest:

  • 6,024 SHORT trades (80%)
  • 1,510 LONG trades (20%)

Reason: During the backtest period, MCX Crude Oil had a predominantly declining MA21 slope. The system correctly identified this bearish bias and took mostly short trades.

This is NOT a flaw - it shows the system adapts to market conditions.

Direction Determination Algorithm

<source lang="python"> def determine_direction(ma21_slope, mtf_direction):

   """
   THE PRIMARY FILTER - Direction must align with MA21 slope.
   This filter runs BEFORE any other analysis.
   """
   if ma21_slope > 0.0001:  # 0.01% threshold
       return LONG  # Rising MA = LONG only
   elif ma21_slope < -0.0001:  # -0.01% threshold
       return SHORT  # Declining MA = SHORT only
   else:  # Flat MA
       return mtf_direction  # Use multi-timeframe consensus

</source>


PART 4: ENTRY CONDITIONS (Gate Checks)

Overview: Hard vs Soft Filters

Filter Type Behavior Examples
HARD Must pass ALL or NO TRADE MA21 slope, hour filter, price in zone, grade
SOFT Affects score but doesn't block MTF alignment, market state, penalties

HARD FILTERS (Must Pass ALL)

These filters block trades entirely if any one fails:

1. MA21 Slope Alignment

  • Direction MUST match MA21 slope
  • Rising MA = LONG only
  • Declining MA = SHORT only
  • Fail = NO TRADE

2. Price in MA Zone

  • Price must be within ±25 points of MA21
  • Too far above/below = not a pullback entry
  • Fail = NO TRADE

3. Hour Filter

  • Block hours: 9, 22, 23 (market open/close volatility)
  • Allowed: 10:00 AM - 9:00 PM IST
  • Fail = NO TRADE

4. Setup Quality Grade

  • Must achieve grade A+, A, or B (score ≥ 70)
  • Grade C/D/F = not good enough quality
  • Fail = NO TRADE

SOFT FILTERS (Affect Score)

These filters affect the quality score but don't block trades:

Filter Effect Impact
MTF Alignment 30% weight in grading Low alignment = lower score
Creeper Move -50 penalty Can still pass if base high
Railroad Trend +15 bonus Quality boost
Price-MA Struggle -30 penalty Can still pass
Wrong Trend Phase -25 penalty Can still pass
Institutional Fight 0.7x multiplier Reduces but doesn't block

Filter Flow Diagram

PRICE BAR RECEIVED
       │
       ▼
┌──────────────────────────────────────────┐
│  HARD FILTER 1: MA21 Slope Alignment     │
│  Is direction aligned with MA21 slope?   │
│  Rising MA + LONG signal = ✓             │
│  Rising MA + SHORT signal = ✗ NO TRADE   │
└──────────────────────────────────────────┘
       │ PASS
       ▼
┌──────────────────────────────────────────┐
│  HARD FILTER 2: Price in MA Zone         │
│  Is price within ±25 pts of MA21?        │
│  YES = ✓  |  NO = ✗ NO TRADE            │
└──────────────────────────────────────────┘
       │ PASS
       ▼
┌──────────────────────────────────────────┐
│  HARD FILTER 3: Hour Filter              │
│  Is current hour allowed?                │
│  Hours 10-21 = ✓  |  9,22,23 = ✗ NO TRADE│
└──────────────────────────────────────────┘
       │ PASS
       ▼
┌──────────────────────────────────────────┐
│  SOFT FILTERS: Calculate Quality Score   │
│  • MTF alignment (30%)                   │
│  • Trend strength (20%)                  │
│  • Key level proximity (20%)             │
│  • Entry quality (15%)                   │
│  • Risk/Reward (15%)                     │
│  ± Penalties and Bonuses                 │
└──────────────────────────────────────────┘
       │
       ▼
┌──────────────────────────────────────────┐
│  HARD FILTER 4: Grade Check              │
│  Score ≥ 70 = Grade B+ = ✓ TRADE        │
│  Score < 70 = Grade C- = ✗ NO TRADE     │
└──────────────────────────────────────────┘
       │ PASS
       ▼
    GENERATE SIGNAL

PART 5: MULTI-TIMEFRAME (MTF) ANALYSIS

Note: MTF is a SOFT FILTER (30% weight). It contributes to the quality score but does NOT block trades on its own. A trade with poor MTF alignment can still pass if other factors compensate.

Timeframe Hierarchy

We analyze 5 timeframes from highest to lowest:

Timeframe Purpose Weight
Daily (1D) Context/Bias Highest weight
4-Hour (4H) Primary Trend High weight
1-Hour (1H) Confirmation Medium weight
15-Min (15M) Entry Timing Lower weight
5-Min (5M) Execution Lowest weight

Per-Timeframe Analysis

For each timeframe, the Trend Analysis Core calculates:

1. Trend Direction

MA21 Slope Direction
> +0.01% UP
< -0.01% DOWN
Between ±0.01% SIDEWAYS
MA Slope Magnitude Status
> 0.05% TRENDING (MA is clearly moving)
< 0.05% FLAT (MA is consolidating)

3. Price-MA Struggle Detection

Condition Detection Impact
Price within 0.5% of MA21 for multiple bars STRUGGLING -30 penalty
Price clearly moving away from MA21 CLEAR TREND No penalty

Alignment Score Calculation

For each timeframe:
  - Check if direction matches expected direction
  - Assign weight based on timeframe importance

Alignment Score = Σ(Weight_i × Aligned_i) / Σ(Weight_i)

Example:
  Daily: UP (aligned) × 1.0 weight = 1.0
  4H: UP (aligned) × 0.86 weight = 0.86
  1H: UP (aligned) × 0.72 weight = 0.72
  15M: DOWN (not aligned) × 0.58 weight = 0
  5M: UP (aligned) × 0.44 weight = 0.44

  Score = (1.0 + 0.86 + 0.72 + 0 + 0.44) / (1.0 + 0.86 + 0.72 + 0.58 + 0.44)
        = 3.02 / 3.60 = 0.84 (84% alignment)

PART 6: MARKET STATE DETECTION

The system detects 7 market state patterns that affect setup quality:

1. Railroad Trend Detection

What: Strong, consistent trend with minimal pullbacks.

Characteristic Threshold
Bar Analysis 5 most recent bars
Strong Bars 80%+ must close in same direction
Bar Body > 0.3% of price

Impact: +15 bonus to setup score


2. Creeper Move Detection

What: Slow, grinding price action with small bars.

Characteristic Threshold
Bar Range Average < 0.5% of price
Analysis Period Last 7 bars

Impact: -50 penalty to setup score (avoid these!)


3. Two-Day Trend Analysis

What: Trend must be visible on Daily for 2+ days.

Requirement Description
Daily Bars 2+ consecutive bars in same direction
Purpose Filters noise, ensures real trend

Impact: Missing = -30 penalty


4. Trend Phase Classification

Phase Bars into Trend Action Impact
EARLY 0-15 bars Avoid -25 penalty
MIDDLE 15-40 bars TARGET No penalty
LATE 40+ bars Avoid -25 penalty

5. Institutional Fight Detection

What: Big players battling each other.

Indicator Sign
Volume 1.5x+ average
Price Action Narrow range with high volume
Wicks Long wicks (rejection)

Impact: 0.7x multiplier on final score


6. Break of Structure (BOS)

What: Price breaking significant swing high/low.

BOS Type Description
SWING_HIGH_BREAK Price breaks above prior swing high
SWING_LOW_BREAK Price breaks below prior swing low
PDH_BREAK Previous Day High break
PDL_BREAK Previous Day Low break

7. Volatility Classification

Volatility ATR % of Price Adjustment
HIGH > 1.0% Wider stops needed
MEDIUM 0.3% - 1.0% Normal stops
LOW < 0.3% Tighter stops

PART 7: SETUP QUALITY GRADING

5-Factor Weighted Scoring

Every potential trade is scored on 5 factors:

Factor Weight What It Measures
Timeframe Alignment 30% How well all timeframes agree
Trend Strength 20% Quality of trend (railroad vs creeper)
Key Level Proximity 20% Is entry near significant level?
Entry Quality 15% Clean entry technique, near MA
Risk/Reward 15% How favorable is the R:R

Score Calculation

Base Score = (TF_score × 0.30) + (Trend_score × 0.20) + (KeyLevel_score × 0.20)
           + (Entry_score × 0.15) + (RR_score × 0.15)

Adjusted Score = Base Score + Bonuses - Penalties

If Institutional Fight: Final Score = Adjusted Score × 0.7

Penalties

Condition Penalty Reason
Creeper Move -50 Poor quality price action
MA Struggle -30 Price fighting the MA
No Two-Day Trend -30 Trend not established
Wrong Trend Phase -25 Not in MIDDLE phase
Far from Key Level -50 No confluence
Far from MA -40 Not a pullback entry

Bonuses

Condition Bonus Reason
Railroad Trend +15 High quality trend
At Key Level +10 Confluence present
Clean Entry +10 Clear technical setup

Grade Thresholds

Grade Min Score Action
A+ 90+ Trade with full conviction
A 80-89 Trade with confidence
B 70-79 Trade normally
C 60-69 NO TRADE
D 50-59 NO TRADE
F <50 NO TRADE

A+ Special Requirements

To achieve A+ grade, ALL must be true:

  • Score ≥ 90
  • All timeframes aligned
  • Entry near MA21 (within ±25 pts)
  • Two-day trend present
  • No institutional fight

PART 8: ENTRY TECHNIQUES

Available Techniques

Universal (Both Directions)

Technique Description
NEAR_MA Entry when price is near MA21 zone (±25 pts)

Long-Specific

Technique Description
GREEN_BAR_AFTER_PULLBACK Green candle after pullback
MA_BOUNCE_LONG Bounce off MA21 in uptrend
BOS_ENTRY_LONG Entry after break of structure (upside)
BREAKOUT_PULLBACK_LONG Pullback after breakout
DISCOUNT_ZONE_LONG Buy in lower zone of range

Short-Specific

Technique Description
RED_BAR_AFTER_RALLY Red candle after rally
MA_BOUNCE_SHORT Rejection from MA21 in downtrend
BOS_ENTRY_SHORT Entry after break of structure (downside)
BREAKOUT_PULLBACK_SHORT Pullback after breakdown
PREMIUM_ZONE_SHORT Sell in upper zone of range

Selection Logic

<source lang="python"> def select_entry_technique(price, ma21, direction, has_bos, has_pullback):

   # Most common: price near MA zone
   if abs(price - ma21) <= 25:
       return NEAR_MA
   # Break of structure detected
   elif has_bos:
       if direction == LONG:
           return BOS_ENTRY_LONG
       else:
           return BOS_ENTRY_SHORT
   # Pullback pattern detected
   elif has_pullback:
       if direction == LONG:
           return GREEN_BAR_AFTER_PULLBACK
       else:
           return RED_BAR_AFTER_RALLY
   # Default: MA bounce
   else:
       if direction == LONG:
           return MA_BOUNCE_LONG
       else:
           return MA_BOUNCE_SHORT

</source>


PART 9: PROBABILITY ZONES

Halves & Thirds Analysis

Based on price position within recent swing range:

Zone Position Continuation Probability
Top Third 67-100% 80% chance of new high
Top Half 50-67% 65% continuation
Bottom Half 33-50% 35% continuation
Bottom Third 0-33% 15% (85% likely lower)

Zone-Based Trading Rules

Zone LONG SHORT
Top Third Allowed (after pullback) Blocked
Bottom Third Blocked Allowed (after rally)

Sideways Market

Zone LONG SHORT
Top Third Blocked (overextended) Allowed
Bottom Third Allowed Blocked

Three-Finger Spread

What: Large separation between Price, MA21, and MA200.

Detection:
- Distance(Price to MA21) > 2% of price
- AND Distance(MA21 to MA200) > 2% of price

Impact: Expect profit-taking soon (bearish for longs, bullish for shorts)

Crash Bar Detection

What: Abnormally large bar indicating structural break.

Characteristic Threshold
Bar Size 2x average bar size
Close Position Within 30% of extreme

Special Rule: Crash bar in sideways market + top zone → Override to SHORT


PART 10: EXIT MANAGEMENT

Overview

Exit Type Trigger Typical Result
Stop Loss Price hits stop (static or trailing) Loss or locked profit
Take Profit Price hits target Winner (always)
Timeout 8 hours elapsed Exit at market

Initial Stop Loss: 40 Points

Method Description
Default 40 points from entry
Structure-Based Below swing low (LONG) / Above swing high (SHORT)
MA-Based MA21 value ± 25 points buffer
Minimum Always at least 40 points

Stop by Entry Technique

Technique Stop Placement
NEAR_MA 40 pts default
BOS_ENTRY Below/above structure (10-bar lookback + 5pt buffer)
MA_BOUNCE Below/above MA21 zone
BREAKOUT_PULLBACK Below/above pullback low/high

DYNAMIC STOP MANAGEMENT

IMPORTANT: Stop loss is NOT static! It moves dynamically to lock in profits.

This explains why 72.3% of exits are "stop" but many are profitable trades!

Phase 1: Breakeven Stop

Trigger: When trade reaches 25 points profit

Parameter Value
Activation 25 points in profit
New Stop Entry price + 2 pts buffer
Purpose Eliminate loss, lock small profit

Example (LONG at 5500):

Entry: 5500
Original Stop: 5460 (40 pts risk)

Price reaches 5525 (+25 pts profit):
→ Stop moves from 5460 to 5502 (entry + 2 buffer)
→ Worst case now = +2 pts profit (NOT -40 loss!)

Phase 2: Trailing Stop (ATR-Based)

Trigger: When trade reaches 20 points profit

Parameter Value
Method ATR_MULTIPLE (adapts to volatility)
ATR Period 14 bars
ATR Multiplier 2.0
Trailing Distance ATR × 2 (dynamic)
Minimum Distance 15 points
Activation 20 points in profit

How It Works:

Current ATR = 12 points
Trailing Distance = 12 × 2 = 24 pts

Price at 5540 (LONG from 5500):
→ New Stop = 5540 - 24 = 5516

Price at 5560:
→ New Stop = 5560 - 24 = 5536 (moved UP)

Price reverses to 5536:
→ EXIT at 5536 = +36 pts PROFIT
→ Shows as "stop" exit but is profitable!

Key Rule: Stop can only move in profitable direction, NEVER back.

Complete Stop Movement Example

LONG Entry: 5500
Original Stop: 5460 (-40 pts risk)
Target: 5560 (+60 pts)

Trade Progress:
─────────────────────────────────────────────────
Price    Profit   Action                Stop Now
─────────────────────────────────────────────────
5500     0        Entry                 5460
5510     +10      Waiting...            5460
5520     +20      Trailing activates    5490 (5520-30)
5525     +25      Breakeven activates   5502 (max of 5490, 5502)
5540     +40      Trail continues       5510
5560     +60      TARGET HIT!           ---

OR if price reverses:
5540     +40      Trail at 5510         5510
5520     +20      Stop unchanged        5510
5510     +10      STOP HIT              EXIT +10 profit
─────────────────────────────────────────────────

Take Profit: 60 Points

Calculation Value
Primary 50% of distance to MA21
Minimum Risk × 1.5 = 40 × 1.5 = 60 pts
Final MAX(50% to MA, 60 pts) = Usually 60 pts

Risk:Reward = 1.5:1

  • Risk 40 pts to gain 60 pts
  • Risk Rs 4,000 to gain Rs 6,000

Timeout: 8 Hours

  • If trade doesn't hit stop or target within 8 hours
  • Exit at current market price
  • Prevents overnight holding
  • Used in 5% of trades (374 out of 7,534)

Slippage Modeling

Exit Type Slippage
Entry (base) +1.0 points
Stop Loss exit +2.0 points (worse fill)
Take Profit exit +0.5 points (limit order)
Market Impact Up to 2.0 points (capped)

PART 11: RISK MANAGEMENT

Position Sizing

Parameter Value
Position Size 1 lot (100 barrels)
Risk per Trade 40 pts × Rs 100 = Rs 4,000
Reward per Trade 60 pts × Rs 100 = Rs 6,000
Max Concurrent 1 trade at a time

Cost Structure

Cost Type Value
Brokerage Rs 20 per lot per leg (Dhan)
CTT 0.01% on sell side
Total Round-trip ~Rs 95 per trade
Total Costs (7,534 trades) Rs 5.93 Lakhs

Risk Metrics

Metric Value
Risk per Trade Rs 4,000 (4% of initial capital)
Risk:Reward 1:1.5 (40:60)
Required Win Rate 40% to break even
Actual Win Rate 57.6% (profitable)

PART 12: SIGNAL GENERATION FLOW

Complete Pipeline

┌─────────────────────────────────────────────────────────────────────────────┐
│                         SIGNAL GENERATION PIPELINE                         │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│  STEP 1: DATA COLLECTION                                                    │
│  ┌─────────────────────────────────────────────────────────────────────┐   │
│  │ • Load OHLCV data for all 5 timeframes                              │   │
│  │ • Calculate MA21 and MA200 for each timeframe                       │   │
│  │ • Calculate ATR for volatility measurement                          │   │
│  └─────────────────────────────────────────────────────────────────────┘   │
│                              ↓                                              │
│  STEP 2: DIRECTION DETERMINATION (HARD FILTER #1)                          │
│  ┌─────────────────────────────────────────────────────────────────────┐   │
│  │ • Calculate MA21 slope on 5-min chart                               │   │
│  │ • Rising slope → LONG only allowed                                  │   │
│  │ • Declining slope → SHORT only allowed                              │   │
│  │ • Flat slope → Use MTF direction                                    │   │
│  └─────────────────────────────────────────────────────────────────────┘   │
│                              ↓                                              │
│  STEP 3: HARD FILTER CHECKS                                                │
│  ┌─────────────────────────────────────────────────────────────────────┐   │
│  │ □ Is price within ±25 pts of MA21?          → NO = SKIP             │   │
│  │ □ Is current hour allowed? (not 9,22,23)    → NO = SKIP             │   │
│  └─────────────────────────────────────────────────────────────────────┘   │
│                              ↓                                              │
│  STEP 4: MULTI-TIMEFRAME ANALYSIS                                          │
│  ┌─────────────────────────────────────────────────────────────────────┐   │
│  │ • Analyze trend direction in 5 timeframes                           │   │
│  │ • Calculate weighted alignment score                                │   │
│  │ • Output: 0.0 to 1.0 alignment score (30% of grade)                │   │
│  └─────────────────────────────────────────────────────────────────────┘   │
│                              ↓                                              │
│  STEP 5: MARKET STATE ANALYSIS                                             │
│  ┌─────────────────────────────────────────────────────────────────────┐   │
│  │ • Railroad Trend Detection (+15 bonus)                              │   │
│  │ • Creeper Move Detection (-50 penalty)                              │   │
│  │ • Two-Day Trend Check (-30 if missing)                              │   │
│  │ • Trend Phase Classification (-25 if wrong)                         │   │
│  │ • Institutional Fight Detection (0.7x multiplier)                   │   │
│  └─────────────────────────────────────────────────────────────────────┘   │
│                              ↓                                              │
│  STEP 6: SETUP QUALITY GRADING                                             │
│  ┌─────────────────────────────────────────────────────────────────────┐   │
│  │ • Calculate 5-factor weighted score                                  │   │
│  │ • Apply penalties and bonuses                                       │   │
│  │ • Assign grade: A+, A, B, C, D, F                                   │   │
│  │ • Grade < B (score < 70) → SKIP                                     │   │
│  └─────────────────────────────────────────────────────────────────────┘   │
│                              ↓                                              │
│  STEP 7: SIGNAL OUTPUT                                                     │
│  ┌─────────────────────────────────────────────────────────────────────┐   │
│  │ • Direction: LONG or SHORT                                          │   │
│  │ • Entry Price: Current close                                        │   │
│  │ • Stop Loss: 40 points (or structure-based)                         │   │
│  │ • Take Profit: 60 points                                            │   │
│  │ • Entry Technique: NEAR_MA, BOS_ENTRY, etc.                         │   │
│  │ • Grade: A+, A, or B                                                │   │
│  └─────────────────────────────────────────────────────────────────────┘   │
│                              ↓                                              │
│  STEP 8: TRADE EXECUTION                                                   │
│  ┌─────────────────────────────────────────────────────────────────────┐   │
│  │ • Apply entry slippage (1 pt)                                       │   │
│  │ • Monitor for stop/target/timeout                                   │   │
│  │ • Update trailing stop when in profit                               │   │
│  │ • Execute exit with appropriate slippage                            │   │
│  └─────────────────────────────────────────────────────────────────────┘   │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

PART 13: BACKTEST RESULTS

Summary Statistics

Metric Value
Period 19 months
Initial Capital Rs 1,00,000
Final Value Rs 26,48,101
Total Profit Rs 25,48,101
Total Return 2,548%
Peak Value Rs 28,35,039
Max Drawdown -78.6%
Total Costs Rs 5,93,160

Trade Statistics

Metric Value
Total Trades 7,534
Winners 4,338 (57.6%)
Losers 3,196 (42.4%)
Profit Factor 1.20
Average Win Rs 3,464
Average Loss Rs 3,904
Largest Win Rs 26,799
Largest Loss Rs 13,217
Avg Holding Time 2.4 hours

Exit Reason Breakdown

Exit Type Count % Notes
Stop 5,444 72.3% Includes trailing stop profits!
Target 1,716 22.8% 100% winners
Timeout 374 5.0% 8-hour limit

Why are 72% stops but 57% winners?

Because of the trailing stop! Many "stop" exits are actually:

  • Breakeven exits (+2 pts)
  • Trailing stop exits (+10 to +50 pts)

The trailing stop LOCKS IN profits, then exits when price reverses.

Direction Distribution

Direction Count %
SHORT 6,024 80%
LONG 1,510 20%

Why 80% SHORT? The market had a predominantly declining MA21 during the backtest period. The system correctly adapted to bearish conditions.

Setup Quality Distribution

Grade Count %
A+ 3,457 45.9%
A 551 7.3%
C 3,526 46.8% (analyzed but NOT traded)

PART 14: KEY STRATEGY PRINCIPLES

  1. MA21 Slope = Direction - The primary hard filter. Rising MA = LONG only, Declining MA = SHORT only.
  1. MA is a ZONE - Enter within ±25 pts of MA21, not just at exact value.
  1. Quality over Quantity - Only trade A+, A, B grades (score ≥ 70).
  1. Avoid Creeper Moves - -50 penalty ensures we skip low-quality price action.
  1. Trade the MIDDLE - Focus on middle phase of trends (bars 15-40).
  1. Dynamic Stop Management - Breakeven at 25 pts, trailing with ATR×2.
  1. 1.5:1 Risk:Reward - Risk 40 pts to gain 60 pts.
  1. Time Discipline - Maximum 8-hour holding, no overnight.
  1. MTF as Soft Filter - Contributes to score (30%) but doesn't block alone.
  1. Trailing Explains Stops - 72% "stop" exits include profitable trailing stops.

APPENDIX A: CONFIGURATION VALUES

Stop/Target Configuration

Parameter Value Source
min_stop_distance 40 points signal_generation_trade_management.py
default_stop_distance 40 points signal_generation_trade_management.py
default_risk_reward 1.5 signal_generation_trade_management.py
min_target risk × 1.5 = 60 pts signal_generation_trade_management.py

Trailing Stop Configuration

Parameter Value Source
enable_trailing_stop True trade_execution_engine.py
trailing_stop_method ATR_MULTIPLE trade_execution_engine.py
atr_period 14 bars trade_execution_engine.py
atr_multiplier 2.0 trade_execution_engine.py
trailing_stop_activation 20 points trade_execution_engine.py
enable_breakeven_stop True trade_execution_engine.py
breakeven_activation 25 points trade_execution_engine.py
breakeven_buffer 2 points trade_execution_engine.py

Grading Configuration

Parameter Value Source
timeframe_alignment_weight 30% setup_quality_detection.py
trend_strength_weight 20% setup_quality_detection.py
key_level_proximity_weight 20% setup_quality_detection.py
entry_technique_weight 15% setup_quality_detection.py
risk_reward_weight 15% setup_quality_detection.py

APPENDIX B: SOURCE CODE REFERENCE

File Purpose
trend_analysis_core.py MA slope calculation, trend direction, price-MA struggle
multi_timeframe_analysis.py MTF alignment scoring across 5 timeframes
market_state_analysis.py 7 market state detection algorithms
setup_quality_detection.py 5-factor grading system with penalties/bonuses
probability_zone_analysis.py Halves/Thirds, Three-Finger Spread, Crash Bar
signal_generation_trade_management.py Entry/Exit logic, stop/target calculation
trade_execution_engine.py Breakeven, Trailing stop, Slippage, Timeout
data_manager.py OHLCV data loading and management

Document generated from code analysis - January 2026

All rules extracted directly from source code implementation