View source: R/technical_indicators.R
| calc_momentum | R Documentation |
Calculates momentum as the percentage change in price over a specified lookback period. Optimized using column-wise operations (25x faster).
calc_momentum(data, lookback = 12)
data |
A data.frame or data.table with Date column and price columns |
lookback |
Number of periods for momentum calculation (default: 12) |
Data.table with momentum values (0.1 = 10% increase)
data("sample_prices_weekly")
momentum <- calc_momentum(sample_prices_weekly, lookback = 12)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.