דלגו לתוכן
פתיחת RaamTrade

Aroon

תוכן זה אינו זמין עדיין בשפה שלך.

A trend-strength + direction indicator. Multi-value: .up, .down, and .oscillator.

Signature

Aroon(period, on=<source>)
Argument Type Required Notes
period int Param or literal Yes Lookback window for the high/low search.
on= symbol or OHLCV field No Source. Defaults to the trade symbol’s close.

Formula

Let N = period. The search window is the last N bars, current bar included.

  • Let i_max = bars since the highest high in that window (0 = the current bar is the high).
  • Let i_min = bars since the lowest low in that window.

Then:

$$ \text{up} = \frac{N - i_{\max}}{N} \times 100 $$

$$ \text{down} = \frac{N - i_{\min}}{N} \times 100 $$

$$ \text{oscillator} = \text{up} - \text{down} $$

i_max and i_min run 0 … N-1, so .up and .down are bounded (0, 100]: they reach 100 on a fresh extreme and bottom out at 100/N when the extreme is the oldest bar in the window, never at 0. The oscillator is bounded [-100, 100].

Interpretation:

  • up ≈ 100 — a new high was hit very recently → strong uptrend.
  • down ≈ 100 — a new low was hit very recently → strong downtrend.
  • both low (< 50) — no recent extreme → ranging market.

Convention

Two details decide the number, and both are chosen to reproduce real exits, not for textbook tidiness. Textbook Aroon is usually written over N + 1 bars (which is what makes 0 reachable); this page said that until 2026-08-17, and it was wrong about what RaamCode runs.

  1. N-bar window, not N + 1. The high/low search spans exactly period bars.
  2. Oldest bar wins a tie. When the same extreme value occurs more than once in the window, i_max / i_min point at the oldest occurrence, so .up / .down take the lower of the tied values.

Why: measured against the real exits of an independently run strategy over a full year, 6 of 6 exits reproduce exactly under this convention, and only 2 of 6 under the documented N + 1 form. The platform’s job is live ≡ historical ≡ what you validated, and agreeing with exits that really happened beats agreeing with a formula in a book. Both the compiled RaamCode Aroon and the built-in indicator implement the same N-bar / oldest-tie rule, so charts, backtests and live all agree.

Warmup

period bars, and readiness is “the window is full”. Read before that and you get the extremes of however many bars have arrived so far (a one-bar window reports up = down = 100), so let warmup cover it rather than trusting an early reading.

Reading values

Aroon is multi-value — you access fields with attributes, not .value.

aroon = Aroon(14, on=self.trade)
aroon.up # decimal 0..100
aroon.down # decimal 0..100
aroon.oscillator # decimal -100..100
if aroon.up > 70 and aroon.down < 30:
...

No crossed_above on multi-value

aroon.crossed_above(50) is RC2_CROSS_MULTIVALUE. Compare fields explicitly:

if aroon.up > 70 and self.trade.is_flat: # ✅

Example

class AroonTrend(Strategy):
"""Long when Aroon flags a strong uptrend."""
period = Param(14, min=5, max=30)
trade = Symbol()
sizing = FixedCapital()
def execute(self):
aroon = Aroon(self.period, on=self.trade)
self.stop_loss(2.5)
if aroon.up > 80 and aroon.down < 20 and self.trade.is_flat:
self.buy(self.trade, reason=f"Aroon up={aroon.up:.0f}")
if aroon.oscillator < 0 and self.trade.is_long:
self.sell(self.trade, self.trade.position, reason="Aroon flipped down")

Notes

  • Aroon is a trend identification tool — it tells you whether you’re trending, not in which direction by itself (both fields are positive). Use the oscillator (up - down) for direction.
  • Pair with a momentum indicator for entry timing — Aroon confirms regime, momentum times the trigger.
  • Field-level chaining (EMA(5, on=aroon.up)) is on the roadmap. For now, smooth the oscillator yourself: track a manual moving average in persistent state.