OPEN-SOURCE SCRIPT
Egan's Pure Structure & S/D Strategy - Backtest

This strategy is a complete systematic approach to trading Market Structure and Supply/Demand (S/D) zones. It combines institutional price action concepts with advanced technical filters to identify high-probability reversal and continuation setups.
The strategy is designed to be fractal, performing exceptionally well on 15m, 1h, and 4h timeframes across Forex, Crypto, and Futures (including NQ/MNQ).
🚀 How It Works
The engine follows a strict 4-step validation process before executing a trade:
Market Structure (BOS): The script identifies "Pivot" highs and lows. A Break of Structure (BOS) occurs when the price closes beyond these levels, shifting the local trend.
Zone Generation: When a BOS occurs, the script automatically identifies the "Supply" or "Demand" zone—specifically the last consolidation or opposing candle before the impulsive move.
Macro Trend Filter: To increase the win rate, trades are filtered by a 200-period EMA. Longs are only allowed in macro-uptrends, and Shorts in macro-downtrends.
Rejection Confirmation: Instead of "blindly" entering a zone, the strategy waits for a Reversal Candle Confirmation. This ensures that buyers or sellers are actually defending the zone before you enter.
🛠 Key Features
Dynamic Risk/Reward Filter: Only takes trades that meet your minimum R:R requirements (e.g., 1.5 or 2.0).
Rejection Candle Entry: Logic to prevent "catching a falling knife" by waiting for price action confirmation inside the zone.
Automatic Position Sizing: Includes a "Risk % Per Trade" engine that calculates your lot size/contracts based on your stop loss distance and account equity.
Futures & Margin Ready: Built-in support for point values (NQ/MNQ/ES) and margin settings for accurate backtesting results.
Clean Dashboard: An on-chart info table shows the details of the last trade, current trend, and R:R metrics.
⚙️ How to Optimize
Pivot Lookback: Increase (15-20) for more conservative structure, or decrease (5-8) for more aggressive scalping.
Macro Filter: Toggle the 200 EMA on/off depending on whether you want to trade pullbacks or only trend continuations.
Timeframes: For the best results, use the 15m timeframe for entries while keeping an eye on the 1h or 4h for overall direction.
⚠️ Disclaimer
Backtested results do not guarantee future performance. Always use proper risk management and test the strategy on a paper trading account before using live capital.
The strategy is designed to be fractal, performing exceptionally well on 15m, 1h, and 4h timeframes across Forex, Crypto, and Futures (including NQ/MNQ).
🚀 How It Works
The engine follows a strict 4-step validation process before executing a trade:
Market Structure (BOS): The script identifies "Pivot" highs and lows. A Break of Structure (BOS) occurs when the price closes beyond these levels, shifting the local trend.
Zone Generation: When a BOS occurs, the script automatically identifies the "Supply" or "Demand" zone—specifically the last consolidation or opposing candle before the impulsive move.
Macro Trend Filter: To increase the win rate, trades are filtered by a 200-period EMA. Longs are only allowed in macro-uptrends, and Shorts in macro-downtrends.
Rejection Confirmation: Instead of "blindly" entering a zone, the strategy waits for a Reversal Candle Confirmation. This ensures that buyers or sellers are actually defending the zone before you enter.
🛠 Key Features
Dynamic Risk/Reward Filter: Only takes trades that meet your minimum R:R requirements (e.g., 1.5 or 2.0).
Rejection Candle Entry: Logic to prevent "catching a falling knife" by waiting for price action confirmation inside the zone.
Automatic Position Sizing: Includes a "Risk % Per Trade" engine that calculates your lot size/contracts based on your stop loss distance and account equity.
Futures & Margin Ready: Built-in support for point values (NQ/MNQ/ES) and margin settings for accurate backtesting results.
Clean Dashboard: An on-chart info table shows the details of the last trade, current trend, and R:R metrics.
⚙️ How to Optimize
Pivot Lookback: Increase (15-20) for more conservative structure, or decrease (5-8) for more aggressive scalping.
Macro Filter: Toggle the 200 EMA on/off depending on whether you want to trade pullbacks or only trend continuations.
Timeframes: For the best results, use the 15m timeframe for entries while keeping an eye on the 1h or 4h for overall direction.
⚠️ Disclaimer
Backtested results do not guarantee future performance. Always use proper risk management and test the strategy on a paper trading account before using live capital.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.