OPEN-SOURCE SCRIPT

Apex Engine Multi Trail

831
Apex Engine Multi Trail- Publication Notes

📖 Overview & Philosophy
Apex Engine V7.0 is not just an indicator; it is a complete, state-driven trading system designed for intraday and swing traders who demand precision, transparency, and adaptability. Unlike simple moving average crosses, this engine uses a multi-layered confirmation architecture to filter out market noise and identify high-probability trade setups.

The core philosophy is "Confluence before action." A trade is only considered when a Primary Trigger (direction) aligns with a Secondary Filter (strength/context) and respects market structure through ORB (Opening Range Breakout) logic. Once in a trade, the engine manages it intelligently using your choice of four distinct Trailing Stop Loss (TSL) methods, each suited to different market personalities. The comprehensive dashboard provides real-time transparency into the engine's "thought process," making it an ideal tool for both manual traders and those seeking to automate with webhooks.

⚙️ 1. Settings & Inputs - A Detailed Guide
Every input in this script serves a specific purpose. Here’s what they do and why you need them:

Group 1: Strategy Selection
Primary Trigger: This is the foundation of your trade direction. It decides whether the market is bullish or bearish.

Supertrend on HMA: Applies the Supertrend formula to a Hull Moving Average (HMA) of the close. It's smoother and more responsive than a standard Supertrend, reducing whipsaws.

Standard Supertrend: The classic, well-known Supertrend indicator based on closing prices. It's reliable for capturing strong trends.

HMA Direction: Simply checks if the Hull Moving Average is sloping up or down. This is the purest, most basic trend filter.

Secondary Filter: This acts as a confirmation mechanism. It ensures the market environment supports the primary signal, adding a crucial layer of safety.

VWAP (Volume Weighted Average Price): An institutional benchmark. A primary Bullish signal above VWAP suggests strong, volume-backed buying pressure.

ADX Strength (Average Directional Index): Measures trend strength, not direction. It confirms if the trend detected by the primary trigger is worth trading.

None: Disables the secondary filter, relying solely on the primary trigger.

Group 2: Visual Settings
Simple checkboxes to toggle chart elements on/off. HMA Momentum Band provides a visual envelope of trend momentum, while the Colored VWAP and Supertrend Line help you visually confirm signals. Color Background by Trend paints the chart for an instant visual assessment of the primary trend.

Group 3: Dashboard Layout & Size
Controls the look and position of the information panel. You can choose its size (Tiny to Large), position (e.g., Top Right), and which sections of the dashboard are visible (Logic, Stats, Running Trade).

Group 4: Core Indicator Settings
HMA Length: The lookback period for the Hull Moving Average. A larger value makes the HMA smoother and less sensitive.

Supertrend ATR Multiplier & ATR Length: Standard Supertrend parameters. A higher multiplier creates a wider band, making the trigger less sensitive but more reliable.

ADX Length & Min ADX Strength: Defines the period for ADX calculation and the minimum value required for the "Strong Trend" filter.

Group 5: Smart Entry Rules
Wait for Candle Close: When enabled, the strategy only acts on the confirmed close of a bar, preventing false signals from intra-bar wicks.

Opening Bar Breakout (ORB): A classic gap-and-go strategy. It uses the first candle's high/low as a filter, ensuring you only trade when price breaks out of its initial balance.

Bars to Wait after SL: A mandatory "cool-down" period after a stop loss is hit. This prevents emotional revenge trading and gives the market time to reset.

Smart Re-entry: An advanced feature that prevents re-entering a trade immediately after a stop loss. It waits for price to reclaim the HMA and make a new high/low, confirming momentum has returned.

Group 6: Time & Square-Off Settings
Essential for intraday traders. You can restrict entries to a specific Allowed Entry Window and, crucially, enable an Auto Square-Off to automatically exit all trades at a pre-defined time (e.g., 3:15 PM), ensuring you don't hold positions overnight.

Group 7: Dynamic ATR Ladder
These inputs define your initial risk (Initial SL) and the fixed step size (Target Step) for the Fixed Step Ladder trailing method. The values are multiples of the ATR at the time of entry, making your risk dynamically adjusted to market volatility.

Group 8: Trailing Stop Method
This is the heart of the trade management system. You can choose how the engine protects your profits.

🧠 2. Entry Logic: How a Trade is Born
A trade is not triggered by a single event but by a confluence of factors. The engine follows a strict checklist:

Primary Trigger Alignment: The market must be either Bullish or Bearish based on your chosen primary indicator.

Secondary Filter Confirmation: The secondary filter must agree. For VWAP, price must be on the correct side. For ADX, the trend must be "Strong."

ORB Condition: If enabled, price must have broken out of the first candle's range. This confirms a decisive move.

Cooldown Period: The engine must not be in a post-stop-loss waiting period.

Time Checks: The trade must be within the allowed session and before the square-off time.

Smart Re-entry Check: If recently stopped out, the market must show signs of reclaimed momentum.

Bar Confirmation: If enabled, the trade is only taken at the bar's close, ensuring the signal is valid.

Only when all applicable conditions are true will the engine execute a trade and print a "BUY" or "SELL" label on the chart. This rigorous process is designed to keep you out of low-probability, noisy market conditions.

📊 3. The Dashboard: Your Command Center
The dashboard is not just for show; it is a critical tool for transparency and trust in the system. It shows you the real-time state of every condition the engine checks, so you're never left guessing why a trade was or wasn't taken .

Trade Logic Monitor: Displays the status of the Primary Trigger, Secondary Filter, Wait Period, Bar Confirmation, and a final "Decision Monitor" that explains in plain English why the engine is flat or active (e.g., "FLAT - Cooling down post-SL").

Closed Trades Statistics: Tracks your performance in real-time, showing total trades, win/loss counts, win rate, and total points for both long and short positions.

Running Trade Monitor: For an active trade, this shows the entry price, current stop loss, the next target (or trailing value), unrealized points ("Run"), and most importantly, the Guaranteed P/L – the profit already locked in by the trailing stop.

This level of detail builds confidence and allows for post-trade analysis directly on the chart.

🛡️ 4. Trailing Stop Loss (TSL) Methods Explained
This is where you customize the engine's "personality." Each method has its own strengths and weaknesses, making the script adaptable to different trading styles.

Method How It Works PROs CONs
Fixed Step Ladder After entry, the first target is hit, stop moves to breakeven. After each subsequent target, the stop moves up by a fixed step_mult (based on entry ATR). Targets are plotted as "T1, T2, T3..." on the chart. Psychologically satisfying with clear targets. Excellent in strong trends as it locks in profits step-by-step. Can be too rigid in volatile markets. A sharp pullback could hit your stop even if the trend is still good. Underperforms in slow, grinding moves where price may not reach the next target.
ATR Trailing The stop is calculated as close - (current_atr * atr_trail_mult) for longs. It trails price continuously and is only raised (or lowered for shorts), never moved back. Highly adaptive to current market volatility. Gives the trade room to breathe in volatile conditions. Excellent for capturing massive trends. Can be too loose in very slow markets, giving back more profit than necessary. Susceptible to being stopped out by a single volatile candle if the multiplier is too small.
Parabolic SAR Uses the built-in Parabolic SAR indicator as the trailing stop. The SAR flips when the trend reverses. Simple and automatic. It accelerates as the trend gains momentum, tightening the stop. Works very well in strong, sustained trends . Notorious for whipsaws in sideways or choppy markets. The SAR can flip frequently, causing multiple small losses.
Moving Average Lowest For a long, the stop is the lowest low of the last N bars. For a short, it's the highest high. Excellent for range-bound or slowly trending markets. It gives the trade a lot of room. Very intuitive – it's like drawing a trend line under the recent price action. Horrible in fast, volatile trends. The stop will be left far behind, giving back a huge portion of profits. React slowly to sudden reversals.
🚨 5. Alerts & Webhook Automation
The script comes pre-configured with four specific alertconditions, making it plug-and-play for automated trading systems that use webhooks.

1. 🟢 ENTER LONG: Triggers when a new long position is opened. The message sent is: {"action": "buy", "ticker": "{{ticker}}"}

2. 🔴 ENTER SHORT: Triggers when a new short position is opened. The message sent is: {"action": "sell", "ticker": "{{ticker}}"}

3. ❌ EXIT LONG: Triggers when an existing long position is closed (by stop loss, square-off, or target). The message: {"action": "close_long", "ticker": "{{ticker}}"}

4. ❌ EXIT SHORT: Triggers when an existing short position is closed. The message: {"action": "close_short", "ticker": "{{ticker}}"}

You can easily create alerts from the TradingView interface using these conditions. The JSON format is clean and ready to be parsed by any trading bot or third-party automation service.

🧩 6. Final Usage Notes & Recommendations
Intended Market: This script is designed for liquid, trending instruments like Indices (NIFTY, BANKNIFTY, S&P 500), Forex majors, and large-cap stocks. It may perform poorly in highly choppy or illiquid markets.

Timeframe: Works on all timeframes, but performs best on 5-minute to 1-hour charts for intraday trading. For swing trading, 1-hour to daily charts are recommended.

Risk Management: The dashboard's Guaranteed P/L is your best friend. Always be aware of your locked-in profit. Never risk more than 1-2% of your capital per trade.

Optimization: Start with the default settings. Use the dashboard to observe how the engine behaves. Only then should you tweak the ATR multipliers or step sizes to suit the specific volatility of your chosen asset.

By understanding each component of this engine, you move from being a passive user to an active, informed trader who knows exactly why your strategy behaves the way it does. Good luck and trade safe. 🚀

כתב ויתור

המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.