MTF Matrix Strategy by Okeefe06

By Okeefe06

Performance Metrics

Description

**MTF Matrix & Hybrid Strategy V2: Smart Trend & Ambush System**> **⚠️ DISCLAIMER:** *This script and the following explanations are strictly for educational and algorithmic coding purposes. It is NOT financial or investment advice. Always backtest strategies thoroughly and apply your own risk management before using them in live markets.*This strategy is designed to eliminate overtrading and only enter the market during the highest-probability moments. It strips away the noise of complex charts: it identifies a strong trend, waits for a discount, and protects your capital with a mathematical armor.**How Does It Work? (3 Simple Steps)**1. **Confirms the Direction (Trend Filter):** The system first checks the 5, 8, and 13 Simple Moving Averages (SMA). If they are aligned perfectly (5 > 8 > 13), it confirms a strong uptrend and activates its "Long-only" mode.2. **Sets the Ambush (The Pullback):** A smart trader never buys the top (No FOMO). This strategy waits for the price to cool down and pull back to the **SMA 8** baseline. This specific zone is defined as the "Ambush Area".3. **Pulls the Trigger (Candle Confirmation):** Once the price drops into the ambush zone, the system doesn't buy blindly. It waits for visual proof of a reversal using Price Action. It executes the trade only if it detects a valid reversal pattern like a Pin Bar, Engulfing, Doji, or Morning Star.**How Does It Manage Risk? (Hybrid Exit Mechanism)**Entering a trade is only half the battle; keeping the money is the real challenge. The system uses a two-layered defense:* **Step-by-Step Profit Locking (D-Levels):** The algorithm calculates invisible Fibonacci targets (D1, D2, D3...) based on the Higher Timeframe (HTF). As the price climbs and breaches these levels, the system automatically trails your stop-loss up to the previous level, locking in your profits step-by-step.* **Dynamic Trailing Stop (The Safety Net):** Just in case of sudden market crashes, it maintains a dynamic trailing stop based on a percentage (e.g., 2%) below the highest seen price. As the peak rises, the stop rises. If the price drops by that percentage, it closes the trade to secure gains or minimize losses.**Customizable Features (Inputs)*** **Ambush Sensitivity (ATR %):** Adjust how close the price needs to get to the moving average before triggering an entry. Widen or narrow the zone based on market volatility.* **Price Action Filters:** Toggle specific candlestick patterns on or off based on your personal preference.* **Live Dashboard:** A sleek panel on the top right gives you real-time visibility of your current stop price, HTF targets, and trade status at a single glance.---### 🇹🇷 TÜRKÇE AÇIKLAMA**MTF Matrix & Hybrid Strategy V2: Akıllı Trend ve Pusu Sistemi**> **⚠️ YASAL UYARI:** *Bu strateji kodu ve aşağıdaki açıklamalar tamamen algoritmik düşünce yapısını incelemek ve kodlama eğitimi amacıyla hazırlanmıştır. Kesinlikle finansal veya yatırım tavsiyesi (YTD) değildir. Gerçek piyasalarda işlem yapmadan önce sistemin matematiğini anlayın, test edin ve kendi risk yönetiminizi uygulayın.*Bu strateji, piyasada sürekli işlem yapma hastalığını ortadan kaldırmak ve sadece "en güvenli" anlarda oyuna dahil olmak için tasarlanmıştır. Karmaşık grafik analizlerini bir kenara bırakır; güçlü bir trend bulur, fiyatın ucuzlamasını bekler ve kârı matematiksel bir zırhla korur. **Sistem Nasıl Çalışır? (3 Basit Adım)**1. **Yönü Teyit Eder (Trend Filtresi):** Sistem ilk olarak 5, 8 ve 13 günlük Basit Hareketli Ortalamalara (SMA) bakar. Eğer bu üçü kusursuz bir sıraya dizilmişse (5 > 8 > 13), piyasanın güçlü bir yükseliş trendinde olduğunu anlar ve sadece "Alım" (Long) yönlü fırsat aramaya başlar.2. **Pusuya Yatar (Geri Çekilme):** Usta bir avcı avının üzerine koşmaz, bekler. Bu strateji de fiyatlar zirvedeyken alım yapmaz (FOMO'yu engeller). Fiyatın, trendin dinlenme bölgesi olan **SMA 8** çizgisine doğru geri çekilmesini bekler. Bu bölge sistemin "Pusu Alanı"dır.3. **Tetiği Çeker (Mum Onayı):** Fiyat pusu alanına geldiğinde sistem körü körüne alım yapmaz. Dönüşün başladığını kanıtlayan bir Price Action (Fiyat Hareketi) mumu arar. Pin Bar, Yutan Mum (Engulfing), Doji veya Sabah Yıldızı formasyonlarından birini gördüğü an işleme girer.**Riski Nasıl Yönetir? (Hibrit Çıkış Mekanizması)**İşleme girmek işin sadece yarısıdır, asıl marifet parayı korumaktır. Sistem bu noktada devreye iki katmanlı bir zırh sokar:* **Adım Adım Kâr Kilitleme (D-Seviyeleri):** Sistem, üst zaman diliminden (HTF) aldığı verilerle görünmez Fibonacci hedefleri (D1, D2, D3...) çizer. Fiyat yükselip bu hedefleri aştıkça, zarar kes (stop-loss) seviyenizi bir alt kademeye taşır. Böylece kazandığınız kârı piyasaya geri vermezsiniz.* **Dinamik İzleyen Stop (Emniyet Kemeri):** İşler ters giderse diye, fiyatın gördüğü en yüksek zirveden belirlediğiniz bir yüzde (örn: %2) gerisine dinamik bir stop koyar. Zirve yükseldikçe stop da yükselir; fiyat aniden %2 düşerse işlemi kârla veya minimum zararla kapatır.**Kullanıcı Dostu Özellikler (Ayarlar)*** **Pusu Hassasiyeti (Ambush Sensitivity):** Fiyatın ortalamaya ne kadar yaklaşması gerektiğini ayarlarsınız. Piyasaya göre alanı daraltıp genişletebilirsiniz.* **Fiyat Hareketi (PA) Filtreleri:** İstemediğiniz mum formasyonlarını ayarlardan kapatıp sadece güvendiklerinizle işlem yapabilirsiniz.* **Bilgi Panosu (Dashboard):** Sağ üst köşedeki şık panel sayesinde anlık stop seviyenizi, hedeflerinizi ve piyasa durumunu tek bakışta görürsünüz.Release Notespdated the script to handle Ambush Sensitivity as a direct percentage input, ensuring it matches the logic of your Trailing Offset. All comments and labels have been translated into English for a clean, professional look.Key Changes:Ambush Logic: Inputting 20 now correctly calculates $20\%$ of the ATR as your entry buffer.Trailing Logic: Stays as a percentage ($2.0 = 2\%$).Comments: Fully converted to English.Code Integrity: All technical indicators (SMAs, EMAs), HTF Fibonacci levels (D1-D5), and Price Action filters remain fully intact and functional.Release NotesAdded Buy price to upper right cornerRelease Notes## Technical Modification Summary### 1. Engine Performance & Execution SpeedThe core execution parameters of the strategy were upgraded to eliminate lag during manual trading.* **Real-Time Calculation**: Enabled `calc_on_every_tick = true`. The strategy now evaluates logic on every price change instead of waiting for the candle to close.* **Immediate Order Routing**: Set `process_orders_on_close = false`. This ensures that orders are executed the moment the criteria are met, preventing the delay typically seen at the open of a new bar.### 2. Enhanced Pattern Recognition (Pin Bar Logic)The Pin Bar formula was refined to ensure higher signal quality by analyzing the relationship between the upper and lower wicks.* **Wick Symmetry Check**: Added a condition where the lower wick must be strictly greater than the upper wick ($lWick > uWick$).* **Body Proportion**: Maintained the requirement that the lower wick must be at least twice the size of the candle body.### 3. Dynamic Entry Confirmation (Fast/Slow Toggle)A logical switch was implemented to allow for tactical flexibility depending on the user's presence at the screen.* **Conditional Entry**: Introduced `entry_confirmed` logic.* **Toggle Mechanism**: When **Fast Mode** is enabled, the strategy treats the signal as valid immediately. When disabled, it reverts to standard `barstate.isconfirmed`, requiring a closed candle for safety.### 4. State Machine & Status Logic RefinementThe internal handling of trade statuses was optimized for clarity and accuracy.* **Bug Fix**: Resolved a conflict in the `if/else` chain that caused the "WAITING" status to flicker or error out.* **Persistent Tracking**: Improved the `max_seen_price` and `stop_px` resets to ensure that the trailing stop logic only resets when a position is fully closed.### 5. Multi-Target Pivot Calculation LogicThe calculation for Fibonacci-based target levels ($D1$ through $D5$) was adjusted for better multi-timeframe stability.* **Lookahead Management**: Utilized `barmerge.lookahead_on` for the daily pivot data to ensure the levels are plotted correctly relative to the current trading session's context.Release NotesFized Hybrid Trailing Enfine to force status updateRelease Notes### 1. Simplified Interface and Status Names (Core Change)We replaced the confusing and disconnected terms on the dashboard and in the alerts with a clean, standardized "Trailing" hierarchy. It is now much easier to read:* Old `BE PROTECTED` ➔ New **`TRAILING (Entry)`** *(When the stop is moved to your breakeven/entry price)** Old `D1, D2, D3 LOCKED` ➔ New **`TRAILING (D1)`**, **`TRAILING (D2)`**, **`TRAILING (D3)`** *(When the stop is locked to upper pivot tiers)** Old `TRAILING` ➔ New **`TRAILING (%)`** *(When the price surges rapidly and the system abandons D-levels to trail strictly by your set percentage)*### 2. Screen Clearing and Memory Reset (Bug Fix)* To prevent the old Stop Loss value from getting "stuck" (showing in red) on the dashboard after a trade hits its target (D5) or gets stopped out, we added the `stop_px := na` command to the exit block.* Now, when a trade finishes, the dashboard resets to a clean "WAITING" mode, and the Stop cell displays an empty dash (`-`).### 3. What ABSOLUTELY Stayed the Same (Preserved Architecture)* **The D5 Take Profit Target:** As we agreed upon for strategic discipline, the `limit=d5` order remains intact. The millisecond the price touches D5, the trade closes with maximum profit (`TARGET REACHED`).* **The Stop-Trailing Math:** The logic of giving the price "room to breathe" by locking the stop to one level below the current price action (e.g., placing the stop at D2 when the price crosses D3) remains mathematically identical.* **The Pending Logic:** The `ENTRY PENDING` mechanism, which represents the limbo phase between a signal firing and the order actually executing on the next tick/bar, is fully preserved.Release Notes[2026-04-21] REVISION v2.0:// 1. ADDED: RSI Negative Divergence Filter to prevent "Top Traps".// 2. ADDED: Toggle switch in settings to Enable/Disable Divergence Filter.// 3. UPDATED: Default RSI Period set to 14.// 4. UPDATED: Default Pivot Lookback set to 7 for stable peak detection.// 5. IMPROVED: All UI/Input labels and comments converted to English.// 6. IMPROVED: Dynamic Alert System covering Entry, Trailing SL, and Exit.// 7. ADDED: Visual Divergence Risk Zone (Red Background) for backtesting.*Try different formations for each target time frame ** Adjust Ambush Sensitivity and trailing distance for different time frames and stocks

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView