Trade automation,
made simple.

Create (or generate with AI) your trading bots,
backtest with confidence, and run them 24/7 on
our cloud infrastructure.

Futures icon Futures
Commodities icon Commodities
Crypto icon Crypto
momentum.ts
Live
// Runs on every candle close
export default async function on_candle_close(ctx: Context) {
  // Calculate EMAs
  const ema20 = ExponentialMovingAverage.calculate(20, ctx.series);
  const ema9 = ExponentialMovingAverage.calculate(9, ctx.series);

  // Get EMA for current and last candles
  const current_ema20 = ema20[ema20.length - 1];
  const current_ema9 = ema9[ema9.length - 1];

  const prev_ema20 = ema20[ema20.length - 2];
  const prev_ema9 = ema9[ema9.length - 2];

  // Calculate cross
  const crossed_above = prev_ema9 <= prev_ema20 &&
      current_ema9 > current_ema20;

  const crossed_below = prev_ema9 >= prev_ema20 &&
      current_ema9 < current_ema20;

  // Execute trade
  if (crossed_above) {
    console.log(`🚀 BULLISH CROSSOVER!`);

    await ctx.close_all_positions();
    await ctx.new_order({
      ctid_trader_account_id: ctx.account_id,
      symbol_id: ctx.symbol.symbol_id,
      order_type: OrderType.MARKET,
      trade_side: TradeSide.BUY,
      volume: 100,
    });
  } else if (crossed_below) {
    console.log(`📉 BEARISH CROSSOVER!`);

    await ctx.close_all_positions();
    await ctx.new_order({
      ctid_trader_account_id: ctx.account_id,
      symbol_id: ctx.symbol.symbol_id,
      order_type: OrderType.MARKET,
      trade_side: TradeSide.SELL,
      volume: 100,
    });
  }
}
Status
Running
PnL (USD) +2,345.67
Win rate 63.42%
Trades 128
Uptime 7d 14h
Chart example

Connect to leading brokers & exchanges see all

BUILT FOR TRADERS & DEVELOPERS Everything you need to automate your edge

Code icon

Code or generate

Write your bot in TypeScript or use AI to generate strategies in seconds.

backtest icon

Backtest & optimize

Backtest on high-quality data and optimize parameters with ease.

cloud icon

Deploy to cloud

Run your bots 24/7 on our reliable infrastructure with low latency (around 2ms per execution)

chart icon

Monitor & analyze

Track performance in real-time with advanced analytics and alerts.