OPEN-SOURCE SCRIPT

Fair Value Breakout Strategy by @tradingbauhaus

The **Breakaway Fair Value Gaps (BFVG) Strategy** is a trading approach designed to identify and capitalize on significant price gaps that occur within the context of a strong trend. These gaps, known as Fair Value Gaps (FVGs), represent areas where the price moves sharply, leaving behind an imbalance between supply and demand. When these gaps occur during a breakout or a strong trend continuation, they are referred to as **Breakaway Fair Value Gaps (BFVGs)**. This strategy uses these gaps as key levels for entering trades and managing risk.

---

### **Key Concepts**
1. **Fair Value Gap (FVG)**:
- A FVG occurs when the price moves sharply, leaving a gap between the high/low of previous candles and the current candle.
- It represents an imbalance in the market where buyers or sellers are overwhelmingly dominant.

2. **Breakaway Fair Value Gap (BFVG)**:
- A BFVG is a FVG that occurs during a strong trend or breakout, signaling potential continuation of the trend.
- It acts as a key level for entering trades in the direction of the trend.

3. **Mitigation Levels**:
- These are price levels where the market might retrace to "fill the gap" before continuing in the direction of the trend.
- The strategy monitors these levels to determine if the gap is still valid or if it has been mitigated.

---

### **Strategy Rules**
#### **Entry Conditions**
1. **Bullish BFVG**:
- A bullish BFVG occurs when:
- The current low is higher than the high of two candles ago (`low > high[2]`).
- The close of the previous candle is higher than the high of two candles ago (`close[1] > high[2]`).
- **Entry**: Go long (buy) when a bullish BFVG is detected and the price has not yet mitigated the gap.

2. **Bearish BFVG**:
- A bearish BFVG occurs when:
- The current high is lower than the low of two candles ago (`high < low[2]`).
- The close of the previous candle is lower than the low of two candles ago (`close[1] < low[2]`).
- **Entry**: Go short (sell) when a bearish BFVG is detected and the price has not yet mitigated the gap.

#### **Exit Conditions**
1. **Stop Loss**:
- The stop loss is placed at a fixed percentage below the entry price for long trades (`stop = close * (1 - stopLossPerc / 100)`).
- For short trades, the stop loss is placed at a fixed percentage above the entry price (`stop = close * (1 + stopLossPerc / 100)`).

2. **Take Profit**:
- The take profit is placed at a fixed percentage above the entry price for long trades (`limit = close * (1 + takeProfitPerc / 100)`).
- For short trades, the take profit is placed at a fixed percentage below the entry price (`limit = close * (1 - takeProfitPerc / 100)`).

#### **Mitigation Levels**
- If the price retraces and closes within the gap (mitigates the FVG), the gap is considered invalid, and the strategy stops monitoring it.

---

### **Visualization**
- **BFVG Boxes**:
- Bullish BFVGs are highlighted with a green box.
- Bearish BFVGs are highlighted with a red box.
- **Mitigation Lines**:
- Horizontal lines are drawn at the high/low of the gap to indicate the mitigation levels.

---

### **Dashboard**
The strategy includes a dashboard that displays key statistics:
1. **Total BFVGs Detected**:
- The number of bullish and bearish BFVGs identified.
2. **Mitigation Percentage**:
- The percentage of BFVGs that have been mitigated.
3. **Average/Median Duration**:
- The average or median number of candles it takes for a BFVG to be mitigated.

---

### **How It Works**
1. **Trend Identification**:
- The strategy uses a moving window of `length` candles to determine the current trend (highs and lows).
2. **Gap Detection**:
- It scans for FVGs that meet the criteria for BFVGs (strong trend context).
3. **Trade Execution**:
- Enters trades in the direction of the BFVG and manages risk using stop loss and take profit levels.
4. **Mitigation Monitoring**:
- Tracks whether the price retraces to fill the gap, invalidating the BFVG.

---

### **Advantages**
1. **Trend-Following**:
- The strategy capitalizes on strong trends, which often lead to significant price movements.
2. **Clear Entry and Exit Levels**:
- BFVGs provide well-defined levels for entering trades and managing risk.
3. **Flexibility**:
- Parameters like `length`, `stopLossPerc`, and `takeProfitPerc` can be adjusted to suit different trading styles.

---

### **Example**
- **Bullish BFVG**:
- The price is in an uptrend. A bullish BFVG is detected, and a long trade is entered.
- The stop loss is placed 1% below the entry price, and the take profit is placed 2% above.
- **Bearish BFVG**:
- The price is in a downtrend. A bearish BFVG is detected, and a short trade is entered.
- The stop loss is placed 1% above the entry price, and the take profit is placed 2% below.

---

### **Conclusion**
The **Breakaway Fair Value Gaps Strategy** is a systematic approach to trading strong trends by identifying and exploiting price gaps. It combines clear entry signals with robust risk management, making it suitable for traders who prefer trend-following strategies. By monitoring mitigation levels and using a dashboard for performance tracking, the strategy provides a comprehensive framework for trading BFVGs.
Bands and ChannelsBill Williams IndicatorsCandlestick analysis

סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יוכלו להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אבל השימוש החוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

רוצה להשתמש בסקריפ זה בגרף?


Join my trading community! 📈

🔹 Discord: discord.gg/7Fwru9gqbS
🔹 YouTube: youtube.com/@TradingBauhaus
🔹 Instagram: instagram.com/tradingbauhaus/

See you inside! 🚀
גם על:

כתב ויתור