Momentum Indicator (MOM)
Indicator that compares the current price of an asset with prices from previous periods to calculate the momentum.
Last updated
Indicator that compares the current price of an asset with prices from previous periods to calculate the momentum.
Last updated
// Prints the current 20 period MOM value using
// the daily bars close price value.
mom = indicators.Momentum(20).OnSeries(dailyBars.Close);
Log("The current MOM value is " + mom.Value.ToString());
// Prints the previous MOM value
mom = indicators.Momentum(20).Keep(2).OnSeries(dailyBars.Close);
Log("The previous MOM value is " + mom.Values[1].ToString());using Signals.DataSeries.Bars;
using Signals.Framework;
using Signals.Indicators.Momentum;
public class MyStrategy : SingleMarketStrategy
{
private Bars dailyBars;
private Momentum mom;
public override void Setup(DataMarketplace data, IndicatorsMarketplace indicators)
{
dailyBars = data.Bars(BarPeriodType.Day, 1).WithOffset(25);
mom = indicators.Momentum(20).Keep(2).OnSeries(dailyBars.Close);
}
public override void RegisterActions()
{
OnUpdateOf(dailyBars).Do(() =>
{
// Prints the current MOM value
Log("The current MOM value is " + mom.Value.ToString());
// Prints the previous MOM value
Log("The previous MOM value is " + mom.Values[1].ToString());
});
}
}