Why Pivot Points Still Matter for Intraday Traders
I’ve been trading with pivot points since my early days in forex, and I still use them daily. They’re not a magic bullet—nothing is—but they provide a structured, objective framework for identifying key price levels that institutional traders and market makers often respect. Unlike lagging indicators that repaint or smooth data, pivot points are calculated from the previous day’s (or week’s) high, low, and close, giving you static levels that hold meaning throughout the session.
The problem is that manually watching these levels and executing trades is exhausting, especially if you trade multiple instruments or timeframes. That’s where a Pivot Point Breakout EA comes in. It automates the calculation, entry, stop-loss, and take-profit logic, freeing you to focus on higher-level decisions like risk allocation and market context. In this post, I’ll walk you through building a robust MQL4 EA that trades breakouts of daily and weekly pivot levels for intraday setups, with real code snippets and practical considerations.
Understanding Pivot Point Breakout Strategy
The core idea is simple: price often reacts at or near pivot levels (PP, R1, R2, S1, S2, etc.). A breakout above a resistance pivot (R1 or R2) signals bullish momentum, while a breakdown below a support pivot (S1 or S2) signals bearish momentum. The strategy I’ll implement uses the standard floor pivot formula:
- Pivot Point (PP) = (High + Low + Close) / 3
- Resistance 1 (R1) = (2 × PP) – Low
- Resistance 2 (R2) = PP + (High – Low)
- Support 1 (S1) = (2 × PP) – High
- Support 2 (S2) = PP – (High – Low)
For intraday trading, I use daily pivots (calculated from the previous day’s data) and optionally weekly pivots for stronger levels. The EA will calculate these levels at the start of each trading day (or week) and then monitor price action for breakouts. A breakout is defined as price closing above a resistance level (for buys) or below a support level (for sells) on the current timeframe, followed by a retest or immediate momentum entry.
I prefer a retest confirmation approach: after a breakout, wait for price to pull back to the broken level and then enter in the breakout direction. This reduces false breakouts, which are common in choppy markets. The EA will include an option to disable retest for aggressive traders.
Practical MQL4 Implementation
EA Structure and Input Parameters
Let’s design the EA with clear, configurable inputs so you can adapt it to your style. Here’s the input table:
| Parameter | Type | Default | Description |
|---|---|---|---|
| PivotType | int | 0 | 0=Daily, 1=Weekly |
| BreakoutLevel | int | 1 | 1=R1/S1, 2=R2/S2 |
| UseRetest | bool | true | Wait for retest before entry |
| LotSize | double | 0.1 | Fixed lot size |
| StopLossPips | int | 20 | Stop loss in pips |
| TakeProfitPips | int | 40 | Take profit in pips |
| MaxSpread | int | 30 | Maximum spread in points |
These inputs give you flexibility. For example, setting PivotType=1 and BreakoutLevel=2 will trade breakouts of weekly R2/S2, which are very strong levels. The MaxSpread filter is crucial for avoiding bad fills during news events.
Core Code: Calculating Pivot Levels
In MQL4, you calculate pivot levels using the iHigh(), iLow(), and iClose() functions on the daily or weekly timeframe. Here’s a function that returns the pivot levels in an array:
//+------------------------------------------------------------------+
//| Calculate pivot levels |
//+------------------------------------------------------------------+
void CalculatePivotLevels(int pivotType, double &levels[])
{
double high, low, close;
datetime startTime;
int shift = 1; // previous completed period
if(pivotType == 0) // Daily
{
high = iHigh(NULL, PERIOD_D1, shift);
low = iLow(NULL, PERIOD_D1, shift);
close = iClose(NULL, PERIOD_D1, shift);
}
else // Weekly
{
high = iHigh(NULL, PERIOD_W1, shift);
low = iLow(NULL, PERIOD_W1, shift);
close = iClose(NULL, PERIOD_W1, shift);
}
double pp = (high + low + close) / 3.0;
double range = high - low;
levels[0] = pp; // Pivot Point
levels[1] = 2 * pp - low; // R1
levels[2] = pp + range; // R2
levels[3] = 2 * pp - high; // S1
levels[4] = pp - range; // S2
}
This function runs once per new bar (on the 1-hour or 30-minute chart, for instance). You store these levels in global variables and use them for trade decisions.
Breakout Detection and Entry Logic
The EA checks for breakouts on each tick. For a buy breakout of R1 (if BreakoutLevel=1), the condition is:
bool buyBreakout = (Bid > levels[1]) && (Close[1] <= levels[1]); // price just crossed above
If UseRetest=true, we wait for price to pull back to within RetestDistance pips of the level before entering. A simple implementation:
bool retestBuy = (Bid >= levels[1] - retestPips * Point) && (Bid <= levels[1] + retestPips * Point);
Once both conditions are met, the EA sends a market order with the configured stop loss and take profit. I recommend using OrderSend() with error handling:
int ticket = OrderSend(Symbol(), OP_BUY, LotSize, Ask, 3,
Ask - StopLossPips * Point, Ask + TakeProfitPips * Point,
"Pivot Breakout", 0, 0, Green);
if(ticket < 0) Print("OrderSend failed: ", GetLastError());
For sell breakouts, reverse the logic using Bid and OP_SELL.
Pros, Cons, and Risks
Let’s be honest about what this EA can and cannot do. I’ve seen too many traders over-optimize pivot strategies and get burned.
Pros
- Objective levels: Pivot points are deterministic and don’t repaint, unlike some moving average-based systems.
- Works across markets: Effective on forex, indices, and commodities during liquid hours.
- Simple to code and test: The logic is straightforward, making it easy to backtest and tweak.
- Complementary: You can combine with volume or RSI for higher probability setups.
Cons
- False breakouts: In ranging markets, price often spikes through a pivot level only to reverse. The retest filter helps but isn’t foolproof.
- Dependence on volatility: On low-volatility days, breakouts may not reach take profit before reversing.
- Timeframe sensitivity: Works best on 30-minute to 1-hour charts. On 5-minute, noise dominates.
Risks
- Overtrading: The EA can fire multiple signals per day. Use a maximum daily trade limit to avoid revenge trading.
- Spread and slippage: During major news, spreads widen and your stop loss may get hit even if the level holds. Always use
MaxSpread. - Curve-fitting: Don’t optimize stop loss and take profit to past data too aggressively. A 20/40 pip ratio is a reasonable starting point for most forex pairs.
Example Walkthrough: Trading EUR/USD with Daily Pivots
Let’s run through a realistic scenario. Suppose it’s a Tuesday morning, and you have the EA attached to a 1-hour EUR/USD chart with daily pivots, BreakoutLevel=1, UseRetest=true, StopLossPips=20, TakeProfitPips=40.
- Pivot calculation: The EA calculates Monday’s pivot levels: PP=1.1050, R1=1.1080, S1=1.1020.
- Breakout: At 09:15 GMT, price rises to 1.1085, crossing R1. The EA detects a buy breakout but doesn’t enter yet because
UseRetest=true. - Retest: Price pulls back to 1.1078 (within 3 pips of R1). The EA sends a buy order at 1.1080 (Ask).
- Stop






