Tool
MA Trend (Stack)
market.ma_trend
Inputs
No typed inputs.
Outputs
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.
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
Builds the three MAs as exponential averages, weighting recent bars more so the stack reacts faster to turns.
When to use: Use EMA when you want the trend bias to flip quickly as a move develops.
Builds the three MAs as simple averages, giving a smoother, slower-turning stack.
When to use: Use SMA when you want a steadier bias that ignores short-lived whips.
Source options
Build all three MAs from each bar's open price.
When to use: Use open when that price best reflects the move you trade.
Build all three MAs from each bar's high price.
When to use: Use high when that price best reflects the move you trade.
Build all three MAs from each bar's low price.
When to use: Use low when that price best reflects the move you trade.
Build all three MAs from each bar's close price. The usual choice.
When to use: Use close when that price best reflects the move you trade (the default).
Build all three MAs from the median price, the midpoint of high and low.
When to use: Use the median when you want to ignore where price opened and closed.
Build all three MAs from the typical price, the mean of high, low, and close.
When to use: Use the typical price when you want close to count alongside the range.
Build all three MAs from the average price, the mean of open, high, low, and close.
When to use: Use the average price for the smoothest, most balanced input across the bar.
Configuration
Averaging family for all three MAs: ema (recent-weighted, faster) or sma (equal-weight, smoother).
Window of the fastest MA, the one nearest price. Smaller = quicker to react. Default 10.
Window of the middle (anchor) MA whose slope is measured for the trend test. Default 20.
Window of the slowest MA, the trend backbone. Larger = the stack only flips on bigger moves. Default 50.
Which price feeds all three MAs: open, high, low, close, hl2 (median), hlc3 (typical), or ohlc4 (average). Close is usual.
How many bars back to measure the anchor MA's slope. Larger smooths out the slope reading; smaller makes it more sensitive. Default 5.
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
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.