Skip to content
StatePath
Tool Atlasmarket.ma_trend

Tool

MA Trend (Stack)

market.ma_trend

MarketTrend

Inputs

No typed inputs.

Outputs

Bundle (untagged)

A trend-bias bundle: the regime (up / down / range), an alignment flag for the three MAs, the anchor slope, and a 0-to-1 strength score.

MA Trend reads three stacked moving averages (fast, mid, slow) plus the slope of the anchor MA to label the market as up, down, or ranging. Traders use it as a one-stop trend-bias gate instead of eyeballing several averages.

MA Trend (Stack) overview diagramfastmidslow

How it works

It computes three MAs over fast_period, mid_period, and slow_period from the chosen price. When they line up (fast above mid above slow, or the reverse) and the anchor MA's slope over slope_lookback bars exceeds min_slope, it reports a trend; otherwise it reports a range.

Modes

Ma type options

EMA stackema

Builds the three MAs as exponential averages, weighting recent bars more so the stack reacts faster to turns.

EMA stack diagramfastmidslow

When to use: Use EMA when you want the trend bias to flip quickly as a move develops.

SMA stacksma

Builds the three MAs as simple averages, giving a smoother, slower-turning stack.

SMA stack diagramfastmidslow

When to use: Use SMA when you want a steadier bias that ignores short-lived whips.

Source options

Openopen

Build all three MAs from each bar's open price.

Open diagram

When to use: Use open when that price best reflects the move you trade.

Highhigh

Build all three MAs from each bar's high price.

High diagram

When to use: Use high when that price best reflects the move you trade.

Lowlow

Build all three MAs from each bar's low price.

Low diagram

When to use: Use low when that price best reflects the move you trade.

Closeclose

Build all three MAs from each bar's close price. The usual choice.

Close diagram

When to use: Use close when that price best reflects the move you trade (the default).

HL2 (Median Price)hl2

Build all three MAs from the median price, the midpoint of high and low.

HL2 (Median Price) diagram

When to use: Use the median when you want to ignore where price opened and closed.

HLC3 (Typical Price)hlc3

Build all three MAs from the typical price, the mean of high, low, and close.

HLC3 (Typical Price) diagram

When to use: Use the typical price when you want close to count alongside the range.

OHLC4 (Average Price)ohlc4

Build all three MAs from the average price, the mean of open, high, low, and close.

OHLC4 (Average Price) diagram

When to use: Use the average price for the smoothest, most balanced input across the bar.

Configuration

ma_typeenum

Averaging family for all three MAs: ema (recent-weighted, faster) or sma (equal-weight, smoother).

Choices:emasma
fast_periodscalar

Window of the fastest MA, the one nearest price. Smaller = quicker to react. Default 10.

mid_periodscalar

Window of the middle (anchor) MA whose slope is measured for the trend test. Default 20.

slow_periodscalar

Window of the slowest MA, the trend backbone. Larger = the stack only flips on bigger moves. Default 50.

sourceenum

Which price feeds all three MAs: open, high, low, close, hl2 (median), hlc3 (typical), or ohlc4 (average). Close is usual.

Choices:openhighlowclosehl2hlc3ohlc4
slope_lookbackscalar

How many bars back to measure the anchor MA's slope. Larger smooths out the slope reading; smaller makes it more sensitive. Default 5.

slope_lookback diagram
min_slopescalar

Minimum slope of the anchor MA (ATR-normalized) for the stack to count as a trend rather than drift. 0.0 admits any slope; raise it to demand a steeper, clearer trend.

Connects to

Feeds into

Examples

  • Gate entries on the regime: only allow longs when MA Trend reports up.
  • Raise min_slope so the strategy sits out shallow, drifting markets and only trades steep trends.

Common mistakes

  • Setting the three periods too close together, so the MAs never separate and the stack rarely confirms a trend.
  • Leaving min_slope at 0.0 in choppy markets, which lets a flat, aligned stack read as a trend.

See also