Sometimes the number a rule needs isn't on the chart yet. Twice the average range. The midpoint of two levels. This bar's volume as a multiple of normal. The Math node builds it from values you already have, so a Comparison, an Entry or a stop can use it.
- Takes
- One to five numbers, depending on the operation
- Gives
- One number
- Reach for it
- The value a rule needs is arithmetic on values you already have
How it works
Pick the operation from the menu on the node. Each one takes its inputs a little differently:
| Operation | Inputs | Gives |
|---|---|---|
| Add | 2 to 5 | a + b + c ... |
| Subtract | 2 to 5 | a − b − c ... |
| Multiply | 2 to 5 | a × b × c ... |
| Divide | Exactly a and b | a ÷ b |
| Max, Min | 2 to 5 | The largest, or the smallest |
| Average | 2 to 5 | Their mean |
| Absolute | a only | a without its sign |
Order matters for Subtract and Divide, where a comes first. Wire the inputs in order with no gaps; the builder refuses a skipped one.
The result is in whatever units went in. Points minus points is points, and points divided by points is a plain ratio. That's often the point of a Divide: a ratio means the same thing on ES at 6,000 as it did at 3,000.
Missing values pass straight through. If any input has no value yet (an indicator still warming up, a level that hasn't formed), neither does the result, and a Comparison reading it is false. Division by zero works the same way. It gives no value, never infinity, so a rule built on a ratio sits out the bars where the denominator is zero instead of firing on a nonsense number.
Absolute is the one people forget. Put a Distance from price to VWAP through it, compare the result with a Constant of 2 using Less Than, and you have "within 2 points of VWAP, either side".
Example: volume that's unusual for the time of day
You trade NQ 5m breakouts and only want the ones with real participation behind them. A plain 20-bar average of volume is a poor yardstick: the open trades several times the volume of lunch, so every 09:35 bar looks huge and every 12:30 bar looks dead.
Divide instead. Search the palette for the Relative volume pattern and it drops in as three nodes you can see and edit: a Price History reading the last completed bar's volume, another reading the average volume at this time of day over the last 20 sessions, and a Divide. A reading of 1.0 is a normal bar for that time of day; 1.5 is half again as much. Wire the Divide into a Comparison, Greater Than or Equal, against a Constant of 1.5, and AND that with your breakout.
Settings
Use something else when
When it doesn't behave
My ratio is empty on some bars
One of its inputs has no value on those bars, or the denominator is zero. Neither gives a number, and any Comparison reading it is false there. Check the inputs on the chart first. A time-of-day average, for instance, has nothing to give until enough sessions have traded that slot.
The builder says an input is skipped
The wires don't run a, b, c in order. Move the wire on c to b, or remove the extra input. Absolute only reads a, and Divide only a and b.
My long's trailing stop is refused for using Min
A long's stop should only ever move up, so the ratchet that holds it is a Max (the higher of the current stop and the new candidate). Min is the short's version. The builder refuses the wrong one for the trade's direction.
Going further
The Bracket Order's stop modes are made of Math nodes, and you can watch it happen. Set a long's bracket to ATR trailing and the builder lays out an ATR times a Constant of 2 (a Multiply), price minus that (a Subtract), and the higher of the result and the current stop (a Max), wired into the bracket's stop override. A short gets an Add and a Min. Change the Constant to change the multiple. The Max is the ratchet: it's why the stop never steps back.
Every Constant feeding a Math node is a parameter Optimize can sweep. A multiplier is an easy thing to tune until it fits the past perfectly, so sweep in wide steps and keep a reason for the range.