MACD with fixed 12 and 26 periods (MACD Fix (12,26))
MACD with the periods fixed at 12 and 26 — the original definition, and what many data vendors publish as the MACD.
Only the signal period is settable. It measures and is read exactly as MACD is; this entry exists so that a chart can state that the periods are the fixed ones rather than a choice.
01The study, live
Computed by Bentrix’s own code over the same synthetic bars on every page — an illustration of how the study behaves, not a market.
What this figure shows
The figure is computed over 300 sample bars. MACD Fix (12,26) has no value on the first 33 — the bars it needs before it can answer — and its first value stands on bar 34. Its line runs between -0.0021 and 0.0023 on these bars, and the last value is 0.00066. Counting the conditions the study declares on these bars: crosses above 0 twice; crosses below 0 twice; crosses above its signal line 9 times; crosses below its signal line 9 times; the histogram turns up 33 times; the histogram turns down 34 times. Press a condition under the figure to see each place marked. As states rather than moments: is above 0 on 130 bars; is below 0 on 137 bars; is above its signal line on 98 bars; is below its signal line on 169 bars.
02Its parts, named
03What you see
MACD Fix is two lines and a histogram around zero in a pane of its own: the difference of a 12-period and a 26-period exponential average of price, its signal line, and the histogram of the gap between them. The 12 and the 26 cannot be changed; the signal's period is its only input.
04Where it comes from
Gerald Appel developed the MACD in the late 1970s; the histogram was added by Thomas Aspray in the mid-1980s. Appel describes its use in Technical Analysis: Power Tools for Active Investors (2005). The 12 / 26 / 9 defaults date from those early years.
05The formula
MACD Fix = EMA_0.15(P) − EMA_0.075(P)
Signal = EMA(MACD Fix, N), Histogram = MACD Fix − Signal
The two averages of the line are fixed: their smoothing constants are 0.15 and 0.075, the classic decimal stand-ins for 2/13 and 2/27 — a 12 and a 26-period EMA. Only the signal's period (9) is an input.
The line is the gap between the fast and the slow average, in price units. Positive means the fast average is above the slow one.
06A worked example
Take the closes 20, 21, 23, 22, 24, 25, 24, 26 with a fast EMA of 2, a slow EMA of 4 and a signal of 2. Each average starts on the fourth bar, at the plain average of its own window ending there: 22.50 for the fast one (the closes 23 and 22) and 21.50 for the slow one.
On the last bar the fast EMA reads 25.39 and the slow one 24.62.
Line = 25.39 − 24.62 = 0.77
The line from the fourth bar on is 1.00, 1.00, 1.00, 0.47, 0.77. The signal is an EMA of that line, started at the average of its first two values; on the last bar it reads 0.73. The histogram is the difference of the two: 0.77 − 0.73 = 0.04.
MACD Fix does exactly this with the two EMAs fixed at 12 and 26; only the signal period is an input. MACD Fix uses the constants 0.15 and 0.075 for the two averages, the classic decimal approximations of 2/13 and 2/27, so MACD Fix differs from MACD (12, 26) in the later decimals.
MACD Fix itself needs more than eight bars. On Bentrix's hundred-bar sample wave — closes of 100 + 0.05 i + 2 sin(2π i / 20) for bars i = 0 to 99, a 20-bar wave two points high on a slow rise, each bar opening at the close before, its high and low half a point beyond its body — with the signal at 9, the line reads −0.062 on the last bar, its signal 0.070 and the histogram −0.133.
07Built in Assay
The same study written in Assay, Bentrix’s script language, and drawn by Bentrix itself as the script’s graph: each block is one step of the formula. On the ladder the steps stand in the script’s order, one a row; on the board each wire carries a value from the block that gives it to the block that reads it, left to right. The script computes exactly what the study computes — Bentrix checks the two against each other, candle by candle.
//@version=6 indicator("MACD Fix (12, 26)") signalLength = input.int(9, "Signal") // A MACD whose two averages are fixed at 12 and 26; only the signal is chosen. [macd, signal, histogram] = talib.MACDFIX(close, signalLength) plot(macd, "MACD") plot(signal, "Signal") plot(histogram, "Histogram", style = plot.style_histogram)
Paste it into the Assay IDE to put it on a chart, or to change it. Looking at the graph is free in every package; editing it as blocks is Plus.
08Readings — what traders look for
The zero line. The line crossing above zero is read as the 12-period EMA moving above the 26-period EMA — the same event as those two averages crossing.
The line crossing its signal is read as the gap between the averages starting to widen or narrow.
The histogram's height is read as how fast that gap is changing; a shrinking histogram as the gap's change slowing.
Divergence between the line's peaks and price's peaks is one of the most common readings of all.
How the signal crossing fails. In a market without direction the two averages stay close, the MACD line hovers near zero and it crosses its signal again and again. Gerald Appel's own writing reads crossings far from zero differently from crossings near it.
How the zero line fails. A crossing of zero is the two EMAs crossing each other — an event that arrives well after the turn in price, by the lag of the slower average.
09In different markets and timeframes
MACD Fix behaves as MACD (12, 26) does: a trend-following momentum line for markets that trend. Only the signal can be changed.
Twelve and 26 bars are about two and a half and five weeks of daily bars, the span Appel designed for; on M1 they are 12 and 26 minutes. In a market that trends for many times those spans the line stays on one side of zero and the signal crossings mark the trend's pauses; in a range narrower than the slow average's reach the line hovers at zero and crosses its signal on every swing. Its values are in price units and are not comparable between instruments.
10With other studies
Read beside MACD (12, 26, 9), from which it differs in the last decimals because its two constants are the rounded 0.15 and 0.075.
11What it does not tell you
MACD Fix is built from two moving averages and inherits their lag: every crossing comes after the price move that produced it. Its values are in price units, so they cannot be compared between markets or across long periods with very different prices — PPO fixes that.
12Inputs and defaults
- 1Period — 9The signal line's EMA period. The two averages of the MACD line itself are fixed at 12 and 26.
- 2Applied price — CloseAny of the seven prices, and several at once, each its own line with its own look.
- 3Timeframe — ChartThe chart's own by default; any higher one, read on the last closed candle. A finer one is never offered.
- 4Wait for the candle to close — OnThe value of a higher timeframe is taken only from a candle that has finished.
The settings in use
- In use9 for the signal; shorter gives earlier, more frequent crossings.
13Limits and common misreadings
It is TA-Lib's form. MACD Fix is computed as TA-Lib's MACDFIX function computes it, with an EMA signal. MetaTrader 5's own MACD draws its main line as a histogram and its signal as an SMA; that form is a setting of the MACD study, on its own page.
14Conditions an alert or a strategy can watch
an event happens on one bar a state holds on every bar while it lasts
These are the conditions the study itself declares — the same rules the alert editor and the strategy engine read, and the ones the figure's chips show.
15Practise it in the laboratory
Put MACD (12, 26, 9) and MACD Fix (9) in two panes and compare the last digits of a few values: they agree in shape and differ slightly in the decimals.
Open the laboratory17In Bentrix
- From the menu: a chart's Indicators button › Oscillators › MACD Fix (12,26), or type MACD Fix (12,26) in its search.
- Its settings: the settings card opens when it is added; its legend's name opens it again.
18From an agent or a program
Two tools reach it. study_values computes it over a workbench’s candles up to the clock — no chart needed — and study_attach puts it on a chart, where it is drawn and saved with the chart ({"chart": "<chart uri>", "kind": "macd_fix"}).
The study, as a chart files it
This is a new MACD Fix (12,26)’s entry — its kind, its calculation, the price it reads and its settings. Change a setting here to read it with other inputs.
{
"applied": "close",
"convention": "talib",
"kind": "macd_fix",
"settings": {
"period": 9,
"shape": "period"
}
}An agent
An agent calls the MCP tool with it:
{
"name": "study_values",
"arguments": {
"bench": "bentrix://lab/\u2026/bench/\u2026",
"symbol": "EURUSD",
"timeframe": "H1",
"limit": 5,
"study": {
"applied": "close",
"convention": "talib",
"kind": "macd_fix",
"settings": {
"period": 9,
"shape": "period"
}
}
}
}A program
A program does the same in its language — bench and market as in the built-in indicators guide:
Python
values = client.study.values(bench, market, "H1", {"applied": "close", "convention": "talib", "kind": "macd_fix", "settings": {"period": 9, "shape": "period"}}, limit=5)
print("times:", values["times"])
for line in values["lines"]:
print("line:", line["line"])
print(" newest values:", line["values"])JavaScript
const values = await client.study.values({ bench, symbol: market, timeframe: "H1", study: { "applied": "close", "convention": "talib", "kind": "macd_fix", "settings": { "period": 9, "shape": "period" } }, limit: 5 });
console.log("times:", values.times);
for (const line of values.lines) {
console.log("line:", line.line);
console.log(" newest values:", line.values);
}C#
var values = await client.Study.Values(bench, market, "H1", new Dictionary<string, object?> { ["applied"] = "close", ["convention"] = "talib", ["kind"] = "macd_fix", ["settings"] = new Dictionary<string, object?> { ["period"] = 9, ["shape"] = "period" } }, limit: 5);
Console.WriteLine($"times: {values!["times"]!}");
foreach (var line in values!["lines"]!.AsArray())
{
Console.WriteLine($"line: {line!["line"]!}");
Console.WriteLine($" newest values: {line!["values"]!}");
}Go
values := must(client.Study.Values(ctx, mcp.StudyValuesArgs{Bench: bench, Symbol: market, Timeframe: "H1", Study: map[string]any{"applied": "close", "convention": "talib", "kind": "macd_fix", "settings": map[string]any{"period": 9, "shape": "period"}}, Limit: mcp.Ptr[int64](5)}))
fmt.Println("times:", at(values, "times"))
for _, line := range at(values, "lines").([]any) {
fmt.Println("line:", at(line, "line"))
fmt.Println(" newest values:", at(line, "values"))
}Java
Object values = client.study.values(new Bentrix.StudyApi.ValuesArgs(bench, market, "H1", obj("applied", "close", "convention", "talib", "kind", "macd_fix", "settings", obj("period", 9, "shape", "period"))).limit(5L));
System.out.println("times:" + " " + at(values, "times"));
for (Object line : (List<Object>) at(values, "lines")) {
System.out.println("line:" + " " + at(line, "line"));
System.out.println(" newest values:" + " " + at(line, "values"));
}C++
auto values = client.study.values_(StudyApi::ValuesArgs(bench, market, "H1", Json::Object{{"applied", "close"}, {"convention", "talib"}, {"kind", "macd_fix"}, {"settings", Json::Object{{"period", 9}, {"shape", "period"}}}}).limit(5));
std::cout << "times:" << " " << values["times"].dump() << std::endl;
for (const Json &line : values["lines"].arr()) {
std::cout << "line:" << " " << line["line"].dump() << std::endl;
std::cout << " newest values:" << " " << line["values"].dump() << std::endl;
}Julia
values = client.study.values(bench, market, "H1", Dict{String,Any}("applied" => "close", "convention" => "talib", "kind" => "macd_fix", "settings" => Dict{String,Any}("period" => 9, "shape" => "period")); limit = 5)
println("times:", " ", values["times"])
for line in values["lines"]
println("line:", " ", line["line"])
println(" newest values:", " ", line["values"])
endR
values <- client$study$values(bench, market, "H1", list(applied = "close", convention = "talib", kind = "macd_fix", settings = list(period = 9, shape = "period")), limit = 5)
cat("times:", format(values$times), "\n")
for (line in values$lines) {
cat("line:", format(line$line), "\n")
cat(" newest values:", format(line$values), "\n")
}Rust
let values = client.study().values(mcp::StudyValuesArgs::new(bench.clone(), market.clone(), "H1", serde_json::json!({"applied": "close", "convention": "talib", "kind": "macd_fix", "settings": {"period": 9, "shape": "period"}})).limit(5))?;
println!("times: {}", values["times"]);
for line in values["lines"].as_array().into_iter().flatten() {
println!("line: {}", line["line"]);
println!(" newest values: {}", line["values"]);
}Reading the answer
times— the candles’ open times, in milliseconds since 1970 (UTC), oldest first.lines— one entry per line, in this order, each with itslinename and itsvalues;values[i]belongs to the candle attimes[i].- The last value is the candle at the clock’s, which may still be forming: it changes until that candle closes, as on the chart. Nothing after the clock is ever computed.
nullis a candle with no value yet — the warm-up, about 1 × the period at the start of the history.- Its fixed levels, drawn on the chart:
[0.0].
line | What it is |
|---|---|
Main | the indicator's own value |
Signal | a smoothing of the main line, drawn beside it |
Histogram | the gap between the main line and the signal, drawn as bars |
In a strategy
Filed under a key of your choice in a strategy document’s studies — here macd_fix: {"macd_fix": {"applied": "close", "convention": "talib", "kind": "macd_fix", "settings": {"period": 9, "shape": "period"}}} — its rules can name:
| Write | What it is |
|---|---|
macd_fix | its main line, as a value in a compare |
macd_fix.signal | this line, as a value in a compare |
macd_fix.histogram | this line, as a value in a compare |
{"cond": "macd_fix:level.cross_up:0"} | a condition it declares itself |
{"cond": "macd_fix:level.cross_down:0"} | a condition it declares itself |
{"cond": "macd_fix:level.above:0"} | a condition it declares itself |
{"cond": "macd_fix:level.below:0"} | a condition it declares itself |
{"cond": "macd_fix:signal.cross_up"} | a condition it declares itself |
{"cond": "macd_fix:signal.cross_down"} | a condition it declares itself |
{"cond": "macd_fix:signal.above"} | a condition it declares itself |
{"cond": "macd_fix:signal.below"} | a condition it declares itself |
{"cond": "macd_fix:histogram.turns_up"} | a condition it declares itself |
{"cond": "macd_fix:histogram.turns_down"} | a condition it declares itself |
19Sources
- Appel, Gerald. Technical Analysis: Power Tools for Active Investors. FT Prentice Hall, 2005.
- Murphy, John J. Technical Analysis of the Financial Markets. New York Institute of Finance, 1999, ch. 10.
Bentrix 0.1.382Every number, name and default on these pages is read from the application itself.What is comingWhat changed