# Strategy Architecture & Gator Mechanics

**AIMS Entry Alert EA** automates the foundational AIMS momentum strategies, executing trade entries on high-probability momentum shifts while filtering out low-volatility consolidation phases through Williams Alligator alignment rules.

***

## 1. Structural Setup Mechanics[​](#1-structural-setup-mechanics "Direct link to 1. Structural Setup Mechanics")

The engine continuously evaluates price action upon the completion of each newly closed bar (`Bar 1`):



### Setup 1 (S1 — Inside-the-Box Anticipatory)[​](#setup-1-s1--inside-the-box-anticipatory "Direct link to Setup 1 (S1 — Inside-the-Box Anticipatory)")

* **Execution Condition:** Evaluated at the open of a newly closed candle. Triggers when Fast SMA (`InpFasterSMA = 1`, Close) crosses Slow SMMA (`InpSlowerSMA = 5, Shift = 3`, Median) while price operates **inside the channel formed by preceding fractals**.
* **Role:** Captures the early transition phase of a new momentum cycle prior to broader market breakout confirmation.

### Setup 2 (S2 — Confirmed Structural Breakout)[​](#setup-2-s2--confirmed-structural-breakout "Direct link to Setup 2 (S2 — Confirmed Structural Breakout)")

* **Execution Condition:** Triggers when crossing momentum occurs **outside the boundary of preceding fractals**.
* **Role:** A high-conviction continuation breakout confirming directional market expansion.

***

## 2. Alligator Volatility & Trend Alignment Gatekeeper[​](#2-alligator-volatility--trend-alignment-gatekeeper "Direct link to 2. Alligator Volatility & Trend Alignment Gatekeeper")

A common failure mode of basic momentum systems is whipsaw during sideways consolidations. The Alligator filter acts as an objective structural filter:

```
Bullish Alignment: Lips (Green 5/3) > Teeth (Red 8/5) > Jaws (Blue 13/8)

Bearish Alignment: Lips (Green 5/3) < Teeth (Red 8/5) < Jaws (Blue 13/8)
```

* **Sleeping / Intertwined State:** If the moving averages cross, tangle, or deviate from the required sequence, the Alligator is classified as asleep and new entry signals are filtered out.

***

## 3. Order Placement & Breakout Confirmation[​](#3-order-placement--breakout-confirmation "Direct link to 3. Order Placement & Breakout Confirmation")

* **Pending Orders (`InpUsePendingOrders = true`):**

  * **Buy Stop:** Placed at `High[1] + InpBufferPips`. Initial Stop Loss placed at `Jaws (Blue Line) - InpBufferPips`.
  * **Sell Stop:** Placed at `Low[1] - InpBufferPips`. Initial Stop Loss placed at `Jaws (Blue Line) + InpBufferPips + Spread`.
  * **Order Expiration (`InpPendingExpiryBars = 2`):** Unfilled pending orders are cancelled after 2 bars or immediately if Alligator alignment breaks.

* **Runaway Gap Protection (`InpMaxGapPips = 5.0`):**
  * If market price moves more than 5 pips beyond the candle extreme prior to order placement, the pending order is cancelled to prevent chasing adverse slippage.

***

## 4. Exit Rules & Dynamic Trailing[​](#4-exit-rules--dynamic-trailing "Direct link to 4. Exit Rules & Dynamic Trailing")



### Dynamic Blue Line Trailing (Jaws 13/8)[​](#dynamic-blue-line-trailing-jaws-138 "Direct link to Dynamic Blue Line Trailing (Jaws 13/8)")

* As new candles complete, the Stop Loss is ratcheted upward (for Buy positions) or downward (for Sell positions) along the moving Alligator Blue Line.
* Built-in `MODE_FREEZELEVEL` checks prevent modification errors when price is near order boundaries.

### Refined Lips Close Exit (Green Line 5/3)[​](#refined-lips-close-exit-green-line-53 "Direct link to Refined Lips Close Exit (Green Line 5/3)")

* **Candle Close Crossing:** Evaluated strictly on newly closed bars.
* **Grace Period (`InpExitGraceBars = 1`):** Newly entered trades are protected from premature exit during their initial development candle.
* **Profit Gate (`InpExitRequireProfit = true`):** The Lips exit only executes if the position is currently in positive floating profit, preventing premature stop-outs in early retests.
