PROTECTED SOURCE SCRIPT
Rubotics Williams Fractals Strategy

## 📌 Strategy Overview
This script implements a trend-following breakout strategy that uses Williams Fractals for trade entries, moving average filters for trend confirmation, and static stop-loss and take-profit levels based on either swing points or ATR volatility. It is designed for traders looking for a structured, rules-based system with risk-to-reward targeting and clear visual feedback on the chart.
## ✅ Core Components
### 🔷 1. Fractal-Based Entries
The strategy uses Williams-style fractals to detect local highs and lows. A buy stop is placed just above an up fractal when price is trending upwards, and a sell stop is placed just below a down fractal when price is trending downwards. These fractals act as breakout triggers.
* Configurable number of bars (`n`) to define the fractal.
* Optional entry offset in pips to avoid false breakouts.
### 🔷 2. Trend Filter (MA)
To avoid trading against the trend, the system includes a moving average filter. Entries are only allowed:
* Long: if price is above the MA.
* Short: if price is below the MA.
The moving average type is user-selectable (SMA, EMA, WMA, or RMA), with a customizable period.
### 🔷 3. Stop-Loss (SL) Options
You can choose between two SL methods:
* Recent swing high/low: Based on a user-defined lookback.
* ATR-based: SL is set at a multiple of the ATR value at entry.
The script will automatically select the more conservative (wider) SL if both options are enabled.
### 🔷 4. Take-Profit (TP) Modes
TP levels can be calculated in one of two ways:
* Risk:Reward multiple: TP = entry ± (SL distance × RR ratio).
* ATR-based: TP = entry ± (ATR × multiplier).
This gives flexibility in how profit targets are measured and managed.
### 🔷 5. Position Sizing
Orders are sized dynamically based on the percentage of account equity. This helps normalize risk across different market conditions or symbols.
## 📊 Visual Aids & Chart Presentation
The strategy includes helpful visual cues:
* Fractal markers on the chart when new confirmed fractals appear.
* Static horizontal lines for Entry, TP, and SL, visible only while a position is active.
* Color-filled zones:
* Red area between Entry and SL = risk zone
* Green area between Entry and TP = reward zone
These visual layers help users clearly see trade setup logic and risk/reward characteristics.
## 🧪 How the Strategy Works (Summary)
1. Detects new confirmed fractals using the `n/n` lookback logic.
2. Checks if the trend filter (MA) agrees with the direction of the trade.
3. Places a stop order at the next bar once the fractal is confirmed and conditions are met.
4. Upon fill:
* Captures entry price.
* Calculates static TP and SL, which never change after entry.
* Exits the position if either level is hit.
5. Highlights risk/reward zones on the chart until the position is closed.
## ⚠️ Risk Disclaimer
> This strategy is for educational and informational purposes only. It does not constitute financial advice or a trading recommendation. Always test any strategy thoroughly in a simulated environment and ensure it aligns with your personal risk tolerance, trading style, and market understanding. Trading involves risk, and past performance does not guarantee future results.
## 🛠 Customization Options
* Fractal Sensitivity: Adjust `n` for more or less frequent signals.
* MA Filter Type and Length: Adapt to different trends or timeframes.
* Risk Model: Choose between Swing/ATR SL, RR/ATR TP.
* Position Sizing: Set your equity allocation per trade.
* Pip Size & Offset: Tailor to your instrument (e.g., FX, indices, crypto).
## 🔐 Script Transparency
This script is fully open-source. No proprietary logic is hidden. All calculations and logic are visible and editable in the Pine Script code.
## 📅 Best Use Case
Ideal for traders who:
* Prefer price action breakout entries confirmed by trend direction.
* Want clear risk-to-reward setups.
* Appreciate chart-based feedback (e.g., entry/TP/SL lines and zones).
* Are looking for a swing trading strategy adaptable across instruments (FX, crypto, indices, etc.).
Скрипт с защищённым кодом
Этот скрипт опубликован с закрытым исходным кодом. Однако вы можете использовать его свободно и без каких-либо ограничений — читайте подробнее здесь.
Отказ от ответственности
Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.
Скрипт с защищённым кодом
Этот скрипт опубликован с закрытым исходным кодом. Однако вы можете использовать его свободно и без каких-либо ограничений — читайте подробнее здесь.
Отказ от ответственности
Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.