Build / Decision engine
Turn TypeScript into an explicit, testable trading decision.
The Code Editor is Gimmer's current custom-code engine. Write a typed handler that reads the supplied strategy context and returns buy, sell, or neutral while execution and risk remain under Gimmer's control.
Use the supplied context
The handler receives typed bot, strategy, portfolio, and OHLCV data for the current market. Treat that context as the complete decision boundary and return one of the actions supported by the engine.
export default function handler(context: StrategyScriptContext): StrategyDecision {
const closes = context.ohlcv.close || [];
if (closes.length < 2) return "neutral";
return closes[closes.length - 1] > closes[closes.length - 2]
? "buy"
: "neutral";
}
The example is intentionally minimal. It is not a recommended trading strategy and does not account for fees, liquidity, open positions, or market regime.
Write for deterministic failure
- Validate array lengths and numeric values before calculating a signal.
- Use only closed-candle data supplied for the current evaluation.
- Return neutral when data is missing, stale, or outside the expected shape.
- Keep secrets, API keys, wallet material, and unrelated network access out of strategy code.
- Keep the handler small enough that a reviewer can explain every branch that produces an order.
Validate code and execution separately
A correct TypeScript decision can still fail at the exchange because of balance, precision, minimum notional, allowance, nonce, liquidity, or connection errors. Backtest the handler, inspect every trade label, then run simulation while watching Runtime activity and order feedback.
Custom code can automate a mistake
Compilation and type checks do not prove profitability or safety. Review the loss path, simultaneous positions, open equity drawdown, and behavior after exceptions before using real funds.