Grid Masters Temporal Trader MT5 - Complete User-Guide (Part 2)
═══════════════════════════════════════════════════════════════════════════════
GRID MASTERS TEMPORAL TRADER MT5
COMPLETE USER MANUAL AND GUIDE
═════════════════
13. DISCLAIMER & LEGAL
COMPLETE USER MANUAL AND GUIDE - (Part 2)
═══════════════════════════════════════════════════════════════════════════════
5. OPERATIONAL GUIDE
═══════════════════════════════════════════════════════════════════════════════
5.1 HOW THE EA OPERATES DAILY
──────────────────────────────
DAILY CYCLE:
00:00 SERVER TIME - DAILY RESET
├─ All time slot flags reset (g_fired1/2/3 = false)
├─ EA ready to trigger at configured times
└─ Existing positions/orders remain active
TIME SLOT 1 TRIGGERS (e.g., 05:00)
├─ EA checks: Is g_fired1 already true? No → Continue
├─ Market available? Spread OK? Yes → Continue
├─ Check SMA filter (if enabled)
├─ Price > SMA? → Place BUY grid only
├─ Price < SMA? → Place SELL grid only
├─ SMA disabled? → Place both grids
├─ Set g_fired1 = true (won't fire again today)
└─ Grid deployed successfully
CONTINUOUS MONITORING (EVERY TICK)
├─ Check existing positions:
│ ├─ Break-even reached? → Move SL to BE + offset
│ ├─ Trailing trigger? → Adjust trailing SL
│ ├─ Basket profit target? → Execute partial close
│ └─ Position age limit? → Close aged positions
├─ Check trim engines:
│ ├─ Position count > Legacy Trim max? → Trim positions
│ └─ Position count > AI Trim max? → AI trim positions
├─ Check locks:
│ ├─ Equity Lock reached? → Close all, clear grid
│ ├─ Profit Lock reached? → Close all, freeze (optional)
│ └─ Drawdown Lock reached? → Close all, clear grid
├─ Check grid refresh:
│ └─ 70% of pending orders consumed? → Re-deploy grid
└─ Repeat every tick
TIME SLOT 2 TRIGGERS (e.g., 10:00)
├─ Same process as Slot 1
└─ Independent of Slot 1 (fresh grid)
TIME SLOT 3 TRIGGERS (e.g., 15:00)
├─ Same process as Slot 1
└─ Independent of Slots 1 & 2
23:59 SERVER TIME
├─ Day cycle completes
└─ Tomorrow: Reset at 00:00
5.2 GRID PLACEMENT LOGIC
─────────────────────────
STEP-BY-STEP PROCESS:
1. TRIGGER CHECK
├─ Current server time = Time Slot X?
├─ Has this slot already fired today?
└─ If no → Proceed to Step 2
2. MARKET VALIDATION
├─ Is market open and tradable?
├─ Is spread within acceptable range?
├─ Is enough free margin available?
└─ If all yes → Proceed to Step 3
3. SMA ANALYSIS (if enabled)
├─ Calculate current SMA value
├─ Compare mid-price to SMA
├─ Determine bias:
│ ├─ Price > SMA → BUY_ONLY
│ ├─ Price < SMA → SELL_ONLY
│ └─ Filter disabled → BOTH
└─ Proceed to Step 4
4. POSITION LIMIT CHECK
├─ Count current BUY positions
├─ Count current SELL positions
├─ If BUY count >= Max BUY → Skip BUY grid
├─ If SELL count >= Max SELL → Skip SELL grid
└─ Proceed to Step 5
5. PENDING ORDER LIMIT CHECK
├─ Query broker's max pending orders limit
├─ Count current pending orders on account
├─ Would placing grid exceed limit?
└─ If yes → Abort, log warning
6. DELETE OLD PENDING ORDERS
├─ Loop through all pending orders
├─ If order belongs to this EA (magic match):
│ └─ Delete order
└─ Clear the slate for fresh grid
7. PLACE BUY GRID (if allowed)
├─ Calculate BUY levels to place (respecting position limits)
├─ For each level (1 to BuyLevels):
│ ├─ Calculate price: Current + (Level × Spacing)
│ ├─ Calculate SL: Price - SL_Points (if SL > 0)
│ ├─ Calculate TP: Price + TP_Points (if TP > 0)
│ ├─ Validate price against stop-level rules
│ ├─ Check margin for this lot size
│ └─ Place Buy Stop pending order
└─ BUY grid complete
8. PLACE SELL GRID (if allowed)
├─ Calculate SELL levels to place (respecting position limits)
├─ For each level (1 to SellLevels):
│ ├─ Calculate price: Current - (Level × Spacing)
│ ├─ Calculate SL: Price + SL_Points (if SL > 0)
│ ├─ Calculate TP: Price - TP_Points (if TP > 0)
│ ├─ Validate price against stop-level rules
│ ├─ Check margin for this lot size
│ └─ Place Sell Stop pending order
└─ SELL grid complete
9. LOG SUCCESS
└─ "Grid placed: X BUY levels, Y SELL levels at Z spacing"
VISUAL EXAMPLE (Grid Spacing = 50 points):
Current Price: 1.1000
SELL GRID: BUY GRID:
1.0850 ← Sell Stop (Level 3) 1.1150 ← Buy Stop (Level 3)
1.0900 ← Sell Stop (Level 2) 1.1100 ← Buy Stop (Level 2)
1.0950 ← Sell Stop (Level 1) 1.1050 ← Buy Stop (Level 1)
↓ ↑
─────────── 1.1000 (CURRENT) ───────────
As price moves:
• Up to 1.1050: BUY position opens
• Down to 1.0950: SELL position opens
• Continues to activate levels as price moves
5.3 POSITION MANAGEMENT FLOW
─────────────────────────────
ONCE POSITIONS ARE OPEN, EA APPLIES (EVERY TICK):
┌──────────────────────────────────────────────────────────────┐
│ POSITION OPENED (from activated pending order) │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 1. BREAK-EVEN CHECK │
│ • Is profit >= Break-Even Trigger? │
│ • Yes → Move SL to Entry + Offset │
│ • No → Skip to next check │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 2. TRAILING STOP CHECK │
│ • Is profit >= Trailing Start? │
│ • Yes → Set SL to Current Price - Trailing Step │
│ • Update SL if price moves further in profit │
│ • No → Skip to next check │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 3. BASKET PARTIAL CLOSE CHECK │
│ • Calculate average profit across ALL positions │
│ • Is average >= Partial Min Profit? │
│ • Has this position been partially closed already? │
│ • Yes to both → Close X% of volume, mark as partial │
│ • No → Skip to next check │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 4. POSITION AGE CHECK │
│ • Calculate position age (days since open) │
│ • Is age >= Close After Days limit? │
│ • Yes → Close position entirely │
│ • No → Skip to next check │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 5. TRIM ENGINE CHECK (GLOBAL, NOT PER-POSITION) │
│ • Count total positions across all grids │
│ • Legacy Trim: Count >= Max? → Close X losers/winners │
│ • AI Trim: Count >= Max? → Close X worst equity-impact │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 6. LOCK SYSTEM CHECK (GLOBAL, NOT PER-POSITION) │
│ • Equity Lock: Open P&L >= Target? → Close ALL │
│ • Profit Lock: Total Profit >= Target? → Close ALL │
│ • Drawdown Lock: Equity drop >= Limit? → Close ALL │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 7. SMA CROSS CHECK (if enabled) │
│ • Has price closed opposite to SMA? │
│ • BUY positions + price closed below SMA? → Close all BUY │
│ • SELL positions + price closed above SMA? → Close all SELL│
└──────────────────────────────────────────────────────────────┘
↓
REPEAT EVERY TICK
5.4 TRIM ENGINE ACTIVATION
───────────────────────────
LEGACY TRIM ENGINE EXAMPLE:
Settings:
• Max Positions: 40
• Close Count: 10
• Min Profit: 0.0
• Close Losers First: Yes
Scenario:
• You have 42 open positions
• Positions P&L ranges from -$15 to +$8
Activation:
1. EA counts positions: 42
2. 42 >= 40 → Trigger Legacy Trim
3. Collect all 42 positions into array
4. Sort by profit (losers first):
Position #1: -$15
Position #2: -$12
Position #3: -$10
...
Position #42: +$8
5. Loop through first 10 positions (Close Count = 10)
6. For each:
• Check profit >= Min Profit (0.0)
• If yes → Close position
7. Result: 10 worst losers closed, 32 positions remain
Next tick:
• Position count: 32
• 32 < 40 → No trim needed
AI TRIM ENGINE EXAMPLE:
Settings:
• Max Positions: 45
• Close Count: 5
Scenario:
• You have 47 open positions
• Legacy Trim already fired (was at 42, closed 10, now at 32)
• More positions activated, now at 47
Activation:
1. EA counts positions: 47
2. 47 >= 45 → Trigger AI Trim
3. Record current equity: $1,150
4. Analyze equity slope (equity trend direction)
5. Identify positions causing equity drag:
• Position A: Large loss, heavy drag
• Position B: Medium loss, medium drag
• Position C: Small profit, no drag
...
6. Sort by equity impact (worst first)
7. Close top 5 worst equity-impact positions
8. Result: 5 positions closed, 42 remain
Layered Protection:
• Legacy Trim (40) → First defense
• AI Trim (45) → Backup defense
• Never reaches catastrophic levels
5.5 LOCK SYSTEM TRIGGERS
─────────────────────────
EQUITY LOCK EXAMPLE:
Setting: Equity Lock = 110.0 USD
Scenario:
• Account balance: $1,000
• 15 positions open
• Floating P&L: +$115
Trigger:
1. EA calculates open P&L every tick
2. Open P&L = $115
3. $115 >= $110 → Equity Lock triggered
4. EA immediately:
• Closes all 15 positions
• Deletes all pending orders
• Logs event: "Equity Lock triggered at $115"
5. Realized profit now locked in balance
6. EA continues monitoring (lock can trigger again)
PROFIT LOCK EXAMPLE:
Setting: Profit Lock = 100.0 USD
Setting: Stop Trading After Profit Lock = Yes
Scenario:
• Starting balance (from OnInit): $1,000
• Current balance: $1,120 (made $120 in closed trades)
• Open P&L: -$25
Trigger:
1. EA calculates total profit:
Total = (Current Balance - Starting Balance) + Open P&L
Total = ($1,120 - $1,000) + (-$25)
Total = $120 - $25 = $95
2. $95 < $100 → Not triggered yet
Later:
• Open P&L improves to -$5
• Total = $120 - $5 = $115
3. $115 >= $100 → Profit Lock triggered
4. EA immediately:
• Closes all positions
• Deletes all pending orders
• Sets g_frozen = true (EA stops trading permanently)
• Logs: "Profit Lock triggered - EA FROZEN"
5. EA remains on chart but never trades again
DRAWDOWN LOCK EXAMPLE:
Setting: Drawdown Lock = 200.0 USD
Scenario:
• Account equity peaks at $1,300 (EA records as g_peakEquity)
• Market moves against you
• Equity drops to $1,080
Trigger:
1. EA updates peak equity every tick:
if (current equity > peak equity):
peak equity = current equity
2. Peak = $1,300, Current = $1,080
3. Drop = $1,300 - $1,080 = $220
4. $220 >= $200 → Drawdown Lock triggered
5. EA immediately:
• Closes all positions
• Deletes all pending orders
• Resets peak to current equity ($1,080)
• Logs: "Drawdown Lock triggered - DD: $220"
6. EA continues trading (not frozen, unlike Profit Lock)
═══════════════════════════════════════════════════════════════════════════════
6. STRATEGY SETUPS
═══════════════════════════════════════════════════════════════════════════════
6.1 CONSERVATIVE SETUP (LOW RISK)
──────────────────────────────────
ACCOUNT SIZE: $500 - $1,000
TEMPORAL SETTINGS:
• Time Slot 1: "07:00" (London open)
• Time Slot 2: "13:00" (NY open)
• Time Slot 3: "00:00" (disabled, set to midnight)
GRID SETTINGS:
• Buy Levels: 5
• Sell Levels: 5
• Grid Spacing: 100 points
• SL: 0 (use locks instead)
• TP: 0
POSITION LIMITS:
• Max BUY: 10
• Max SELL: 10
LEGACY TRIM:
• Enable: Yes
• Max Positions: 15
• Close Count: 5
• Min Profit: 0.0
• Losers First: Yes
AI TRIM:
• Enable: Yes
• Trigger Count: 20
• Close Count: 3
BREAK-EVEN:
• Enable: Yes
• Trigger: 300 points
• Offset: 20 points
TRAILING:
• Enable: No
PARTIAL CLOSE:
• Enable: Yes
• Close Percent: 50.0
• Min Profit: 400 points
SMA FILTER:
• Enable: Yes
• Period: 50
• Close on Cross: Yes (strict trend following)
RISK & LOCKS:
• Lot Size: 0.01
• Equity Lock: 20.0 USD
• Drawdown Lock: 100.0 USD
• Profit Lock: 50.0 USD
• Stop After Profit Lock: Yes
• Close After Days: 14
MISC:
• Max Spread: 30 points
• Magic: 111111
• Debug: Yes
EXPECTED BEHAVIOR:
• Very conservative position sizing
• Strict trend following (SMA filter + cross-close)
• Quick profit-taking (Equity Lock at $20)
• Tight drawdown control ($100 max)
• Suitable for small accounts
6.2 MODERATE SETUP (BALANCED)
──────────────────────────────
ACCOUNT SIZE: $2,000 - $5,000
TEMPORAL SETTINGS:
• Time Slot 1: "05:00"
• Time Slot 2: "10:00"
• Time Slot 3: "15:00"
GRID SETTINGS:
• Buy Levels: 10
• Sell Levels: 10
• Grid Spacing: 50 points
• SL: 0
• TP: 0
POSITION LIMITS:
• Max BUY: 20
• Max SELL: 20
LEGACY TRIM:
• Enable: Yes
• Max Positions: 30
• Close Count: 10
• Min Profit: 0.0
• Losers First: Yes
AI TRIM:
• Enable: Yes
• Trigger Count: 35
• Close Count: 5
BREAK-EVEN:
• Enable: Yes
• Trigger: 200 points
• Offset: 10 points
TRAILING:
• Enable: No
PARTIAL CLOSE:
• Enable: Yes
• Close Percent: 50.0
• Min Profit: 300 points
SMA FILTER:
• Enable: Yes
• Period: 50
• Close on Cross: No (allow positions to manage themselves)
RISK & LOCKS:
• Lot Size: 0.05 - 0.10
• Equity Lock: 100.0 USD
• Drawdown Lock: 400.0 USD
• Profit Lock: 200.0 USD
• Stop After Profit Lock: Yes
• Close After Days: 7
MISC:
• Max Spread: 50 points
• Magic: 222222
• Debug: Yes
EXPECTED BEHAVIOR:
• Balanced position sizing
• Moderate grid density
• Reasonable profit targets
• Good for medium accounts
6.3 AGGRESSIVE SETUP (HIGH VOLUME)
───────────────────────────────────
ACCOUNT SIZE: $10,000+
TEMPORAL SETTINGS:
• Time Slot 1: "00:00" (daily reset)
• Time Slot 2: "08:00" (London)
• Time Slot 3: "14:00" (NY)
GRID SETTINGS:
• Buy Levels: 15
• Sell Levels: 15
• Grid Spacing: 30 points
• SL: 0
• TP: 0
POSITION LIMITS:
• Max BUY: 0 (unlimited)
• Max SELL: 0 (unlimited)
LEGACY TRIM:
• Enable: Yes
• Max Positions: 50
• Close Count: 15
• Min Profit: 0.0
• Losers First: Yes
AI TRIM:
• Enable: Yes
• Trigger Count: 60
• Close Count: 10
BREAK-EVEN:
• Enable: Yes
• Trigger: 150 points
• Offset: 10 points
TRAILING:
• Enable: Yes
• Start: 400 points
• Step: 200 points
PARTIAL CLOSE:
• Enable: Yes
• Close Percent: 30.0 (take smaller profits, let more run)
• Min Profit: 200 points
SMA FILTER:
• Enable: No (trade both directions)
• Period: 50
• Close on Cross: No
RISK & LOCKS:
• Lot Size: 0.20 - 0.50
• Equity Lock: 500.0 USD
• Drawdown Lock: 2,000.0 USD
• Profit Lock: 1,000.0 USD
• Stop After Profit Lock: No (keep trading)
• Close After Days: 0 (disabled)
MISC:
• Max Spread: 50 points
• Magic: 333333
• Debug: No (reduce log clutter)
EXPECTED BEHAVIOR:
• High frequency grid trading
• Large position counts
• Larger profit targets
• Accepts larger drawdowns
• Only for well-capitalized accounts
6.4 TREND-FOLLOWING SETUP
──────────────────────────
FOCUS: Ride major trends, avoid counter-trend trades
TEMPORAL SETTINGS:
• Time Slot 1: "08:00" (London session)
• Time Slot 2: "14:00" (NY session)
• Time Slot 3: "00:00" (disabled)
GRID SETTINGS:
• Buy Levels: 12
• Sell Levels: 12
• Grid Spacing: 60 points (wider for trends)
• SL: 0
• TP: 0
POSITION LIMITS:
• Max BUY: 15
• Max SELL: 15
LEGACY TRIM:
• Enable: Yes
• Max Positions: 25
• Close Count: 8
• Min Profit: 0.0
• Losers First: Yes
AI TRIM:
• Enable: Yes
• Trigger Count: 30
• Close Count: 5
BREAK-EVEN:
• Enable: Yes
• Trigger: 250 points
• Offset: 15 points
TRAILING:
• Enable: Yes
• Start: 500 points (let trends develop)
• Step: 250 points (wide trailing)
PARTIAL CLOSE:
• Enable: No (let winners run in trends)
SMA FILTER:
• Enable: Yes
• Period: 100 (slower, major trends only)
• Close on Cross: Yes (exit when trend reverses)
RISK & LOCKS:
• Lot Size: 0.10
• Equity Lock: 200.0 USD
• Drawdown Lock: 500.0 USD
• Profit Lock: 0.0 (disabled, let trends run)
• Close After Days: 0
MISC:
• Max Spread: 40 points
• Magic: 444444
• Debug: Yes
PHILOSOPHY:
• Wide grid spacing suits trending moves
• SMA(100) filters out noise, catches major trends
• Close on Cross exits when trend ends
• Trailing stop locks in trend profits
• No partial close (maximize trend capture)
6.5 RANGE-TRADING SETUP
────────────────────────
FOCUS: Profit from ranging/sideways markets
TEMPORAL SETTINGS:
• Time Slot 1: "06:00" (early London)
• Time Slot 2: "12:00" (London close/NY open overlap)
• Time Slot 3: "20:00" (Asian session)
GRID SETTINGS:
• Buy Levels: 8
• Sell Levels: 8
• Grid Spacing: 40 points (tight for ranges)
• SL: 0
• TP: 100 points (quick scalping TPs)
POSITION LIMITS:
• Max BUY: 12
• Max SELL: 12
LEGACY TRIM:
• Enable: Yes
• Max Positions: 20
• Close Count: 6
• Min Profit: 5.0 (only close profitable ones)
• Losers First: No (secure winners first in ranges)
AI TRIM:
• Enable: Yes
• Trigger Count: 25
• Close Count: 4
BREAK-EVEN:
• Enable: Yes
• Trigger: 150 points
• Offset: 10 points
TRAILING:
• Enable: No (ranges don't trend far)
PARTIAL CLOSE:
• Enable: Yes
• Close Percent: 70.0 (aggressive profit-taking)
• Min Profit: 200 points
SMA FILTER:
• Enable: No (ranges cross SMA frequently)
RISK & LOCKS:
• Lot Size: 0.10
• Equity Lock: 80.0 USD (quick profit-taking)
• Drawdown Lock: 300.0 USD
• Profit Lock: 150.0 USD
• Stop After Profit Lock: No (continue in ranges)
• Close After Days: 5 (don't hold range trades long)
MISC:
• Max Spread: 30 points
• Magic: 555555
• Debug: Yes
PHILOSOPHY:
• Tight grid spacing catches small range moves
• Fixed TP (100 pts) scalps range bounces
• Aggressive partial close (70%) locks range profits
• Short position age (5 days) prevents stale range trades
• No SMA filter (ranges whipsaw around MA)
═══════════════════════════════════════════════════════════════════════════════
7. OPTIMIZATION GUIDE
═══════════════════════════════════════════════════════════════════════════════
7.1 BACKTESTING BEST PRACTICES
─────────────────────────────
Nb please note that the full complete pdf guide is available on request
[Click here for Part 3]
Back testing best practices and the rest of the guide in part 3, wish I could paste the whole thing here but limits.


