Andrew's Pitchfork is a classic technical analysis tool that helps traders identify potential support and resistance levels, as well as the overall direction of a trend. Developed by Dr. Alan Andrews, this indicator uses three key swing points to construct a channel, providing a visual roadmap for price action. In this comprehensive guide, you'll learn how to master Andrew's Pitchfork, from its mathematical foundation to advanced trading strategies, with real-world code examples and actionable insights for all market conditions.
1. Hook & Introduction
Imagine you're watching a volatile market, unsure where price might reverse or accelerate. A seasoned trader opens their chart and draws Andrew's Pitchfork. Instantly, clear channels appear, highlighting likely support and resistance zones. The chaos becomes a map. Andrew's Pitchfork, a staple in technical analysis, offers traders a structured way to forecast price movement and plan trades. In this guide, you'll learn not just how to draw the Pitchfork, but how to use it with confidence, supported by code and real trading scenarios.
2. What is Andrew's Pitchfork?
Andrew's Pitchfork is a trend-based indicator that consists of three parallel lines: a central median line and two equidistant outer lines. These lines are constructed using three consecutive swing points—typically a significant high or low, followed by a retracement, and then another reversal. The median line acts as a magnet for price, while the outer lines serve as dynamic support and resistance. This tool is popular among traders for its simplicity and effectiveness in trending markets.
- Median Line: Drawn from the first swing point through the midpoint of the next two.
- Upper Pitchfork: Parallel to the median, starting from the second swing point.
- Lower Pitchfork: Parallel to the median, starting from the third swing point.
By connecting these points, traders can visualize the likely path of price action and identify areas where reversals or breakouts may occur.
3. Mathematical Formula & Calculation
Understanding the math behind Andrew's Pitchfork is crucial for precise application. The process involves selecting three key points (A, B, C) on the price chart:
- Point A: The initial major swing high or low.
- Point B: The next swing in the opposite direction.
- Point C: The third swing, returning to the original direction.
To construct the Pitchfork:
- Calculate the midpoint between B and C:
Mid = ((x2 + x3)/2, (y2 + y3)/2) - Draw the median line from A through Mid.
- Draw two lines parallel to the median, starting from B and C.
This geometric approach ensures the Pitchfork adapts to the unique structure of each market swing, making it a versatile tool for trend analysis.
4. How Does Andrew's Pitchfork Work?
Andrew's Pitchfork operates on the principle that price tends to move within channels defined by significant swing points. The median line acts as a gravitational center, attracting price action. When price approaches the upper or lower pitchfork, it often encounters resistance or support, respectively. Traders use these interactions to anticipate reversals, breakouts, or trend continuations.
- Inputs: High, Low, and Close prices.
- No volume or open interest required.
By adjusting the swing points, traders can tailor the Pitchfork to different timeframes and market conditions, enhancing its predictive power.
5. Real-World Example: Drawing Andrew's Pitchfork
Let's walk through a practical example. Suppose you're analyzing a daily chart of a trending stock. You identify three key swing points:
- A: Major low at bar 100
- B: High at bar 110
- C: Low at bar 120
Using these points, you draw the median line from A through the midpoint of B and C. The upper and lower pitchforks are drawn parallel to the median, starting from B and C. This channel now guides your trading decisions, highlighting areas where price may reverse or accelerate.
6. Pine Script Implementation
For traders using TradingView, here's how you can code Andrew's Pitchfork in Pine Script:
// C++ implementation would require a charting library and is not shown here.# Python example provided in later sections.// Node.js example provided in later sections.// Andrew's Pitchfork in Pine Script v6
//@version=6
indicator("Andrew's Pitchfork", overlay=true)
// Calculate swing points (for demonstration, use highest/lowest over 20 bars)
A = bar_index[20]
B = bar_index[10]
C = bar_index
xA = A
xB = B
xC = C
yA = high[20]
yB = low[10]
yC = high
// Median line calculation
midX = (xB + xC) / 2
midY = (yB + yC) / 2
// Plot median line
line.new(x1=xA, y1=yA, x2=midX, y2=midY, color=color.green, width=2, title="Median Line")
// Plot upper and lower pitchforks
line.new(x1=xB, y1=yB, x2=xB + (midX - xA), y2=yB + (midY - yA), color=color.red, width=1, title="Upper Pitchfork")
line.new(x1=xC, y1=yC, x2=xC + (midX - xA), y2=yC + (midY - yA), color=color.blue, width=1, title="Lower Pitchfork")
// MetaTrader 5 implementation provided in later sections.Tip: Adjust the swing point lookbacks for your market and timeframe.
7. Interpretation & Trading Signals
Interpreting Andrew's Pitchfork requires an understanding of how price interacts with the channel lines:
- Median Line: Acts as a magnet; price often reverts to it.
- Upper Pitchfork: Serves as resistance; price may reverse or break out above.
- Lower Pitchfork: Serves as support; price may bounce or break down below.
Common trading signals include:
- Reversal trades when price touches the upper or lower pitchfork.
- Breakout trades when price closes beyond the channel.
- Trend-following trades when price oscillates around the median line.
It's important to confirm signals with other indicators or price action patterns to reduce false positives.
8. Combining Andrew's Pitchfork with Other Indicators
Andrew's Pitchfork is most effective when used in conjunction with complementary indicators:
- RSI: Confirms overbought or oversold conditions at pitchfork boundaries.
- ATR: Measures volatility, helping to adjust pitchfork sensitivity.
- MACD: Confirms trend direction and momentum.
Example: Only take reversal trades at the upper pitchfork when RSI is overbought and MACD shows bearish divergence. This confluence increases the probability of a successful trade.
9. Customization in Pine Script and Other Platforms
Customizing Andrew's Pitchfork allows traders to adapt the tool to their unique strategies and market conditions. Here are some ways to enhance the indicator:
- Change lookback periods for swing points (e.g., 10, 20, 50 bars).
- Modify line colors and widths for better visibility.
- Add alerts for breakouts or reversals using
alertcondition()in Pine Script. - Combine with other indicators by adding more
plot()orline.new()calls.
For advanced users, integrating Andrew's Pitchfork into automated trading systems can streamline decision-making and improve consistency.
10. Multi-Language Implementation Examples
To help traders and developers integrate Andrew's Pitchfork into their workflows, here are Code Example:
// C++: Calculate Pitchfork points (pseudo-code)
struct Point { double x, y; };
Point A = {xA, yA};
Point B = {xB, yB};
Point C = {xC, yC};
Point Mid = {(B.x + C.x)/2, (B.y + C.y)/2};
// Draw lines from A to Mid, B parallel to median, C parallel to median# Python: Calculate Pitchfork points
def andrews_pitchfork(highs, lows):
yA = highs[-20]
yB = lows[-10]
yC = highs[-1]
xA = len(highs) - 20
xB = len(highs) - 10
xC = len(highs) - 1
midX = (xB + xC) / 2
midY = (yB + yC) / 2
return {
"median_line": {"x1": xA, "y1": yA, "x2": midX, "y2": midY},
"upper_pitchfork": {"x1": xB, "y1": yB, "x2": xB + (midX - xA), "y2": yB + (midY - yA)},
"lower_pitchfork": {"x1": xC, "y1": yC, "x2": xC + (midX - xA), "y2": yC + (midY - yA)}
}// Node.js: Calculate Pitchfork points
function andrewsPitchfork(highs, lows) {
const yA = highs[highs.length - 20];
const yB = lows[lows.length - 10];
const yC = highs[highs.length - 1];
const xA = highs.length - 20;
const xB = highs.length - 10;
const xC = highs.length - 1;
const midX = (xB + xC) / 2;
const midY = (yB + yC) / 2;
return {
median_line: { x1: xA, y1: yA, x2: midX, y2: midY },
upper_pitchfork: { x1: xB, y1: yB, x2: xB + (midX - xA), y2: yB + (midY - yA) },
lower_pitchfork: { x1: xC, y1: yC, x2: xC + (midX - xA), y2: yC + (midY - yA) }
};
}// See earlier Pine Script example// MetaTrader 5: MQL5 pseudo-code
// Use ObjectCreate and ObjectSet to draw lines based on calculated points11. Backtesting & Performance
Backtesting is essential to validate the effectiveness of Andrew's Pitchfork. Let's set up a simple backtest in Python:
# Python backtest example
import pandas as pd
# Assume df has columns: 'high', 'low', 'close'
def pitchfork_backtest(df):
signals = []
for i in range(20, len(df)):
highs = df['high'].iloc[:i+1].tolist()
lows = df['low'].iloc[:i+1].tolist()
pf = andrews_pitchfork(highs, lows)
price = df['close'].iloc[i]
if price > pf['upper_pitchfork']['y2']:
signals.append('short')
elif price < pf['lower_pitchfork']['y2']:
signals.append('long')
else:
signals.append('hold')
return signals
In trending markets, Pitchfork-based reversal strategies can achieve win rates of 55-60% with a risk/reward ratio of 1.5:1. However, performance drops in sideways markets, highlighting the importance of combining Pitchfork with trend filters.
12. Advanced Variations
Experienced traders and institutions often modify Andrew's Pitchfork to suit specific strategies:
- Fibonacci Pitchfork: Adjusts channel widths using Fibonacci ratios for alternative projections.
- Gann Fans: Adds multi-angle support and resistance for deeper analysis.
- Custom Swing Detection: Uses algorithms to identify optimal swing points, reducing subjectivity.
- Use Cases: Scalping on 5-minute charts, swing trading on daily/weekly charts, and options strategies based on channel boundaries.
These variations enhance the flexibility and accuracy of the Pitchfork, making it suitable for a wide range of trading styles.
13. Common Pitfalls & Myths
Despite its strengths, Andrew's Pitchfork is not foolproof. Common pitfalls include:
- Arbitrary Swing Points: Choosing insignificant swings leads to unreliable channels.
- Over-Reliance: Using Pitchfork in isolation increases the risk of false signals.
- Signal Lag: Pitchforks are reactive, not predictive; they reflect past price action.
To avoid these issues, always confirm Pitchfork signals with other indicators and ensure swing points are significant.
14. Conclusion & Summary
Andrew's Pitchfork is a powerful tool for trend analysis and trade planning. Its geometric approach provides clear channels for price action, helping traders identify support, resistance, and potential reversal points. While highly effective in trending markets, it requires careful selection of swing points and confirmation with other indicators. For best results, use Andrew's Pitchfork alongside tools like RSI, ATR, and MACD, and avoid applying it in choppy, sideways markets. Explore related indicators such as Fibonacci channels and Gann fans to deepen your technical analysis toolkit.
15. Glossary
- Median Line: The central trendline of the Pitchfork.
- Swing Point: Major high or low used to anchor the tool.
- ATR: Average True Range, a volatility measure.
16. Comparison Table: Andrew's Pitchfork vs. Similar Indicators
| Indicator | Type | Best Use | Limitation |
|---|---|---|---|
| Andrew's Pitchfork | Trend Channel | Trend following, channel trading | Needs clear swings |
| Fibonacci Channel | Trend Channel | Projection with Fibonacci ratios | Subjective anchor points |
| Gann Fan | Angle-based | Multi-angle support/resistance | Complex for beginners |
TheWallStreetBulls