MACD Differential

The MACD Differential is the difference between two MACD lines that share the slow EMA and the signal period: MACD(fast) − MACD(slow).

Role in the strategy

SlotAvailableRole
Entry PointNo—
Entry RuleYesFilters entries: allows or denies opening a position.
Exit PointNo—
Exit RuleYesTriggers exits: allows or denies closing a position.

It produces conditions, not order prices: as an entry rule it is ANDed with the entry point and the other entry rules, as an exit rule it is ORed with the other exit rules. See Indicators for the slot semantics.

Logic rules

RuleLong signal is 1 whenShort signal is 1 when
Indicator risesthe line rose on the previous barthe line fell on the previous bar
Indicator fallsthe line fell on the previous barthe line rose on the previous bar
Indicator is higher than the Level linethe line is above the Levelthe line is below −Level
Indicator is lower than the Level linethe line is below the Levelthe line is above −Level
Indicator crosses the Level line upwardthe line crossed above the Level from belowthe line crossed below −Level from above
Indicator crosses the Level line downwardthe line crossed below the Level from abovethe line crossed above −Level from below
Indicator changes its direction upwardthe line formed a valleythe line formed a peak
Indicator changes its direction downwardthe line formed a peakthe line formed a valley

Rises and falls are states; the two direction changes and the two crossings are events, which makes them single-bar triggers for the Generator.

Parameters

ParameterTypeDefaultRangePurpose
Apply toselectCloseOpen, High, Low, Close, Median, Typical, WeightedPrice series the MACD lines are calculated from
Fast MAnumber122 to 1000Fast EMA of the first MACD line
Slow fast MAnumber212 to 1000Fast EMA of the second MACD line
MACD slow EMAnumber262 to 1000Slow EMA shared by both lines
MACD SMAnumber92 to 1000Signal period the exported handles carry (it does not enter the line)
Levelnumber0−1000 to 1000Long threshold; the short threshold is −Level

Calculation

  1. Two MACD lines are computed on the selected price (tech.MACD), one with each fast EMA and the same slow EMA.
  1. The indicator value is the difference between the two lines, drawn as a histogram in its own pane (separatedChart).
  1. The signal SMA is not part of the line: it is the parameter of the iMACD handle the export builds, so it is kept on the form for the EA's sake.

Backtesting

  • The rule is evaluated on the previous (closed) bar; the signal applies to the current bar.
  • The line changes sign when the faster MACD crosses the slower one, which is a momentum shift of a shorter scale.
  • The indicator never changes the entry or exit order price; the level comes from the point indicator.