Create a simple strategy
Start with the existing TypeScript strategy guide if you are building your first custom strategy:
The shortest shape is:
- Create a strategy config.
- Implement
core.ts. - Export a manifest and strategy creator.
- Register the strategy plugin from
tradejs.config.ts. - Run a small backtest.
Minimal Registration
import { defineConfig } from '@tradejs/core/config';
import { basePreset } from '@tradejs/base';
export default defineConfig(basePreset, {
strategies: ['./src/plugins/simpleMa.plugin.ts'],
});
Decision Contract
Your strategy should return:
strategyApi.skip('REASON')strategyApi.entry({ direction, orderPlan })strategyApi.exit({ code, direction })
Keep strategy logic causal: only use data available at the current candle timestamp.
Next: Examples.