Appearance
cs
How do you compare members of a list with each other on one bar? Pass the array request.each returns to a cs.* function: it ranks, standardises, scales or trims the values across members and returns an array in the same order. Each one skips na cells and reads na in them, so a member with no data never moves the others.
ameno
indicator("Momentum z-score of the top 20")
array<string> m = request.universe(20)
array<float> mom = request.each(m, ta.roc(close, 20))
// Each member's distance from the list's mean, in standard deviations,
// then winsorised at 5% each end.
array<float> z = cs.winsor(cs.zscore(mom), 0.05)
plot(array.max(z), "Strongest")Arrays also do arithmetic cell by cell in AmenoScript, so cs.row_sum(pair) + own and mom > array.median(mom) are ordinary expressions. See cs.
cs.rank
AmenoScript only
ameno
cs.rank(source) → array<float>Each cell's percentile among the cells, from 0 to 1, with ties sharing their average.
Fewer than two values, or all of them equal, read na.
| Parameter | Description |
|---|---|
sourcearray<float> | The values, one per member. |
cs.zscore
AmenoScript only
ameno
cs.zscore(source) → array<float>Each cell's distance from the cells' mean, in sample standard deviations.
| Parameter | Description |
|---|---|
sourcearray<float> | The values, one per member. |
cs.scale
AmenoScript only
ameno
cs.scale(source) → array<float>The cells scaled so that their absolute values sum to 1.
| Parameter | Description |
|---|---|
sourcearray<float> | The values, one per member. |
cs.winsor
AmenoScript only
ameno
cs.winsor(source, pct) → array<float>The cells with the lowest and highest pct of them moved to the nearest value kept.
At the default, 0.05 of 50 cells moves the two at each end. It never moves more than half the cells.
| Parameter | Default | Description |
|---|---|---|
sourcearray<float> | The values, one per member. | |
pctseries float | 0.05 | The share of cells to move at each end. |
cs.demean
AmenoScript only
ameno
cs.demean(source, group) → array<float>The cells less their mean, or less the mean of the cells sharing a label when group is given.
A cell whose label is na reads na. A label is a value, so the string "1" and the number 1 are different groups.
| Parameter | Description |
|---|---|
sourcearray<float> | The values, one per member. |
grouparray<string> | One label per member, such as a sector. Left out, one group. |
cs.residual
AmenoScript only
ameno
cs.residual(y, x) → array<float>What's left of y after a straight-line fit on x across the members.
| Parameter | Description |
|---|---|
yarray<float> | The values to explain. |
xarray<float> | The values to fit on, one per member. |
cs.top
AmenoScript only
ameno
cs.top(source, n) → array<bool>An array<bool> that is true on the n largest cells.
A tie goes to the earlier cell, so on a list in rank order, to the better rank.
| Parameter | Description |
|---|---|
sourcearray<float> | The values, one per member. |
nseries int | How many to mark. |
cs.row_sum
AmenoScript only
ameno
cs.row_sum(id) → array<float>One sum per row of a matrix, skipping na. A row with nothing in it reads na, not 0, so a member with no pairs yet doesn't look average.
| Parameter | Description |
|---|---|
idmatrix<float> | The matrix, such as request.pairs' result. |