Skip to content

Moving-price momentum ​

Trades momentum in the moving price.

Kind strategy · Resolution 15m

The opposite view to the discount strategy: buy when the pool price moves above the protocol's moving price with momentum.

Entry. The close crosses above the moving price while it is also above an EMA of the close.

Exit. The close crosses back below the moving price, or falls more than Min premium % below it.

What to try. Run it next to Moving-price discount on the same subnet: one tends to work when the other does not.

Try it ​

On the chart, press /, open Strategies and choose Moving-price momentum. Or copy the source below into the AlphaScript editor and click Add to chart.

Inputs ​

InputTypeDefault
Momentum EMAint20
Min premium %float1

Source ​

From packages/alphascript/examples/moving_price_momentum.as.js.

js
strategy({ name: "Moving-price momentum", version: "0.1", market: "ALPHA:61", resolution: "15m",
           capital: { tao: 100 }, actOn: "confirmed", risk: { maxPriceImpactPct: 0.5, maxDrawdownPct: 25 } });

const emaLen  = input.int("Momentum EMA", 20, { min: 3, max: 200 });
const premium = input.float("Min premium %", 1, { min: 0, max: 20, step: 0.25 });

const mp   = candle.movingPrice;
const ema  = ta.ema(candle.close, emaLen);
const prem = ta.change(candle.close, 0);
const above = ta.crossover(candle.close, mp);
const below = ta.crossunder(candle.close, mp);

plot(mp,  { title: "moving price", color: "#f2b544", style: "step" });
plot(ema, { title: "EMA", color: "#8b98a8" });
plotShape(above, { shape: "circle", location: "belowBar", color: "#2bb889", text: "↑mp" });

event.onCandle((bar) => {
  const pos = account.position();
  const premiumPct = (bar.close / mp.value - 1) * 100;
  if (pos.alpha === 0 && above.value && bar.close > ema.value && premiumPct >= 0)
    trade.buy({ tao: account.equity() * 0.5, maxPrice: pool.price() * 1.01, ttlBlocks: 3, reason: "spot>moving" });
  else if (pos.alpha > 0 && (below.value || premiumPct < -premium))
    trade.closePosition({ reason: below.value ? "spot<moving" : "premium-lost" });
});

AlphaScript language v0.1 · runtime 0.2.0