VaultCharts
Trading Strategystocksforexcrypto

Simple Momentum (1/3/6) Strategy

Long when 1-, 3-, and 6-period momentum are all positive; short when all negative. Configurable lookbacks (default 21, 63, 126 bars).

What is Simple Momentum (1/3/6)?

Uses 1-, 3-, and 6-period (e.g. month) lookbacks for long/short entry. Long when momentum is positive across all three; short when negative across all three. Default periods 21, 63, 126 bars (approx 1m, 3m, 6m on daily). Exits when any shorter-period momentum flips.

Strategy Parameters

ParameterTypeDefaultDescription
period1number21Short momentum period
period2number63Medium momentum period
period3number126Long momentum period

Use Cases

  • Multi-timeframe momentum alignment
  • Stocks and crypto on daily
  • Simple trend following
  • Configurable lookbacks

Strategy Script (JavaScript)

This strategy runs in VaultCharts using the built-in strategy engine. Below is the full script in a readable format. You can copy it or run it directly in VaultCharts.

strategy.jsVaultCharts built-in
module.exports = {
  meta: {
    name: "Simple Momentum (1/3/6)",
    params: {
      period1: { type: "number", default: 21 },
      period2: { type: "number", default: 63 },
      period3: { type: "number", default: 126 }
    }
  },
  compute: (data, params, utils) => {
    const cleanData = data.filter(d =>
      d && Number.isFinite(d.close) && Number.isFinite(d.time) && d.close > 0
    );
    const p1 = params?.period1 ?? 21;
    const p2 = params?.period2 ?? 63;
    const p3 = params?.period3 ?? 126;
    const maxPeriod = Math.max(p1, p2, p3);
    if (!cleanData || cleanData.length < maxPeriod + 5) return { signals: [] };

    const closes = cleanData.map(d => d.close);
    const signals = [];
    let position = null;

    for (let i = maxPeriod; i < cleanData.length; i++) {
      const candle = cleanData[i];
      const c = candle.close;
      const c1 = closes[i - p1];
      const c2 = closes[i - p2];
      const c3 = closes[i - p3];
      if (!c1 || !c2 || !c3 || c1 <= 0 || c2 <= 0 || c3 <= 0) continue;

      const mom1 = (c - c1) / c1;
      const mom2 = (c - c2) / c2;
      const mom3 = (c - c3) / c3;

      const allPositive = mom1 > 0 && mom2 > 0 && mom3 > 0;
      const allNegative = mom1 < 0 && mom2 < 0 && mom3 < 0;

      if (position === 'long') {
        if (mom1 < 0 || mom2 < 0) {
          signals.push({ type: "exit", direction: "long", time: candle.time, price: c, index: i });
          position = null;
        }
        continue;
      }

      if (position === 'short') {
        if (mom1 > 0 || mom2 > 0) {
          signals.push({ type: "exit", direction: "short", time: candle.time, price: c, index: i });
          position = null;
        }
        continue;
      }

      if (!position && allPositive) {
        signals.push({ type: "entry", direction: "long", time: candle.time, price: c, index: i });
        position = 'long';
      }
      if (!position && allNegative) {
        signals.push({ type: "entry", direction: "short", time: candle.time, price: c, index: i });
        position = 'short';
      }
    }
    return { signals };
  }
};

Run Simple Momentum (1/3/6) in VaultCharts

VaultCharts includes this strategy as a built-in option. Backtest it, adjust parameters, and use it on your own data—all stored locally on your device.

Related Strategies

Explore More