"Is it higher than it was?" might be the oldest question in technical trading. The Bars Ago node is how you ask it. Feed it a series, say how far back to look, and it hands you that series' value from that many bars ago. Put it beside the current value in a Comparison and you've got "the 50 EMA is rising" or "RSI is lower than it was five bars back".
- Takes
- One series: an indicator, a price, a level, price action, a memory or another modifier
- Gives
- That series' value N bars back
- Reach for it
- A rule compares a value now with the same value earlier
How it works
The count starts from the bar your rules are reading, which is the last completed bar. Indicators are read on that bar too, so an RSI and a Bars Ago 1 of that RSI are neighbors: the RSI of the latest completed bar, and the RSI of the bar before it. At 0 you get the last completed bar itself.
The bars it counts are its input's own bars. A Bars Ago 1 on an RSI built from a 1-hour series is an hour back, even in a strategy that trades 5-minute bars. And at the very start of the data, before there's anything that far back, the output is empty and a comparison against it reads false.
Like every modifier, it shifts a whole series, which the engine builds before the first bar runs. So its input has to be a series: an indicator, Current Price, a price-action output, an external data source, a level (Price History, Pivot Levels, Event Day or Bands), a Distance in standard deviations, a Since or Capture, a Crossover on the Bar close clock, or another modifier. A Math node, a Constant, a condition or a State Machine won't connect. One caution: Swing Points, Market Structure, Order Block, Fair Value Gap and Multi-Bar Formation keep their own memory through history, and the engine runs a backtest in monthly pieces, so a modifier over one of them reads an empty value for the first bars of each month. The builder warns when you wire one.
Current Price deserves its own warning. On a Comparison it's the live trade price, but a modifier can't hold a live price, so what reaches Bars Ago is the close of each completed bar. Bars Ago 1 of Current Price is the close of the bar before the latest completed one, which is one bar further back than most people expect.
Example: only buy while the 50 EMA is rising
You trade pullbacks on ES 15m and want them only while the trend is climbing. "Price above the 50 EMA" doesn't quite say it, because price can sit above an average that's flat or rolling over. You want the average itself to be going up.
Add an EMA with Period 50 and wire it into a Bars Ago with Value 5. Into a Comparison set to Greater Than, wire the EMA into a and the Bars Ago into b. It's true whenever the 50 EMA is higher than it was five bars (75 minutes) earlier. AND it with your pullback signal through a Logic node into the Entry.
Why five bars and not one? The EMA node's own Slope output already gives the one-bar change, and it flips sign on every small wiggle. Five bars asks for a rise you'd actually see on the chart.
Settings
Use something else when
When it doesn't behave
My hand-built crossover misses some crosses
"Below one bar ago, above now" skips the cross where the fast line touched the slow one, sat on it for a bar, then broke through. On the breaking bar the line was equal one bar ago, not below, so the rule never fires. The Crossover node handles the touch. Use it.
My “previous close” is a bar older than I meant
That's Current Price through a Bars Ago. It reads completed closes counted from the last completed bar, so Value 1 lands on the bar before the previous one. For the close of the latest completed bar, use a Price History reading the close over a one-bar window.
It won't take a Math node as its input
A Math node's result is worked out as the strategy runs, and a modifier needs the whole series up front. Shift the inputs instead: Bars Ago 5 of A, minus Bars Ago 5 of B, is the same number as A minus B five bars ago.
Going further
Modifiers chain, and Bars Ago is the one that makes chains interesting. Take a Rolling Min/Max Modifier giving the highest RSI of the last 10 bars, and a Bars Ago 10 of that same node: now you're comparing this stretch's peak momentum with the previous stretch's. A lower peak while price makes a higher high is the classic fading rally, and its momentum half is those three nodes and a Comparison.
The Value can be swept. Keep the steps coarse (3, 5, 10, 20) and remember what you're tuning: how far back "then" is. Fine-grained sweeps here find whichever lag happened to fit your sample, and every value you try counts against the project's search budget.