OPEN-SOURCE SCRIPT
AMD + IFVG Distribution Strategy

This is the final, fully assembled Pine Script that automates the exact AMD (Accumulation, Manipulation, Distribution) strategy we discussed. It acts as a complete trading system, handling everything from identifying the setup to drawing your risk-to-reward parameters on the chart.
Here is a breakdown of exactly what this code does, step-by-step:
1. The Strict Accumulation Filter
Instead of just looking for any sideways movement, the script uses an ATR (Average True Range) Filter.
It measures the height of the market over the last 20 bars.
It calculates the current volatility (ATR).
If the range is too wide or choppy (height is greater than 1.5 * ATR), the script ignores it. It will only validate the setup if the market is in a genuinely tight, compressed consolidation zone.
2. The Manipulation Sweep & Stop Loss Tracking
Once a tight accumulation range is validated, the script lies in wait.
If the price suddenly breaks below the range, it labels it as manipulating_bull (a trap for retail bears).
As this fakeout happens, the script continuously tracks the absolute lowest point (the extreme wick). It remembers this exact price level because it will eventually become your exact Stop Loss.
3. The Momentum Entry (The IFVG Trigger)
This is where the magic happens to get you in right before the Distribution phase.
The script looks for a Fair Value Gap (FVG) that was created during the manipulation sweep.
The Strong Candle Filter: It waits for a specific type of reversal candle. The price must violently reverse and close through the FVG, turning it into an Inversion Fair Value Gap (IFVG).
To prevent you from entering on a weak, low-volume fakeout, the script demands that this reversal candle be "Strong" (the body must make up more than 50% of the candle, and it must close in the top 25% of its range).
4. Automated Chart Visuals
The moment that strong candle closes and confirms the IFVG, the script draws your entire trade plan on the screen automatically:
The Entry Zone: It plots horizontal dashed lines (- - - -) extending to the right to mark the exact IFVG level where you should enter on the retest.
Stop Loss (SL): It draws an orange line at the extreme wick of the manipulation sweep.
Take Profit (TP): It draws a green line at the opposite side of the original Accumulation box.
Projection Boxes: It colors in a red box for your risk (Entry to SL) and a green/blue box for your reward (Entry to TP) so you can instantly visually verify if the trade is worth taking.
5. Precision Alerts
Finally, it hooks into TradingView's alert system. Because we used alert.freq_once_per_bar_close in the code, the second that strong reversal candle closes, your alert fires. This gives you the signal to set your limit order at the dashed IFVG lines before the massive distribution move takes off.
Here is a breakdown of exactly what this code does, step-by-step:
1. The Strict Accumulation Filter
Instead of just looking for any sideways movement, the script uses an ATR (Average True Range) Filter.
It measures the height of the market over the last 20 bars.
It calculates the current volatility (ATR).
If the range is too wide or choppy (height is greater than 1.5 * ATR), the script ignores it. It will only validate the setup if the market is in a genuinely tight, compressed consolidation zone.
2. The Manipulation Sweep & Stop Loss Tracking
Once a tight accumulation range is validated, the script lies in wait.
If the price suddenly breaks below the range, it labels it as manipulating_bull (a trap for retail bears).
As this fakeout happens, the script continuously tracks the absolute lowest point (the extreme wick). It remembers this exact price level because it will eventually become your exact Stop Loss.
3. The Momentum Entry (The IFVG Trigger)
This is where the magic happens to get you in right before the Distribution phase.
The script looks for a Fair Value Gap (FVG) that was created during the manipulation sweep.
The Strong Candle Filter: It waits for a specific type of reversal candle. The price must violently reverse and close through the FVG, turning it into an Inversion Fair Value Gap (IFVG).
To prevent you from entering on a weak, low-volume fakeout, the script demands that this reversal candle be "Strong" (the body must make up more than 50% of the candle, and it must close in the top 25% of its range).
4. Automated Chart Visuals
The moment that strong candle closes and confirms the IFVG, the script draws your entire trade plan on the screen automatically:
The Entry Zone: It plots horizontal dashed lines (- - - -) extending to the right to mark the exact IFVG level where you should enter on the retest.
Stop Loss (SL): It draws an orange line at the extreme wick of the manipulation sweep.
Take Profit (TP): It draws a green line at the opposite side of the original Accumulation box.
Projection Boxes: It colors in a red box for your risk (Entry to SL) and a green/blue box for your reward (Entry to TP) so you can instantly visually verify if the trade is worth taking.
5. Precision Alerts
Finally, it hooks into TradingView's alert system. Because we used alert.freq_once_per_bar_close in the code, the second that strong reversal candle closes, your alert fires. This gives you the signal to set your limit order at the dashed IFVG lines before the massive distribution move takes off.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。