---
title: "Strategy functions"
description: "In Indicators this is the strategy({ ... }) declaration from ./gen/strategy beside the outputs (the engine's own setting names: capital, quantity, commission…"
order: 30
section: "functions"
---

<!-- source: docs/indicators/functions/strategy-functions.md; generated by packages/cli/scripts/gen-indicator-docs.ts, do not edit -->

# Strategy functions

In Indicators this is the `strategy({ ... })` declaration from `./gen/strategy` beside the outputs (the engine's own setting names: capital, quantity, commission, slippage, perps margin), the order builders in `finalize()` (`strategy.long(id)` / `strategy.short(id)` with `.qty()`, `.limit()`, `.stop()`, `.oca()` and `.send()`; `strategy.exit(id)` with `.from()`, `.stop()`, `.limit()`, `.trail()`; `strategy.close(id)`, `strategy.closeAll()`, `strategy.cancel(id)`, `strategy.cancelAll()`), and the position getters valid in `state()` and `finalize()` (`strategy.positionSize()`, `strategy.positionAvgPrice()`, `strategy.equity()`, `strategy.openProfit()`, `strategy.netProfit()`, the trade counts, `strategy.maxDrawdown()`): the same broker the kScript (legacy) engine runs, driven by the host, with `om backtest run <package>` and the Strategy Tester replaying the trade list from the same bars, params and sheet.

Nearest form: [Strategies overview](../strategies/overview.md) is the model, [Writing strategies](../strategies/writing-strategies.md) the API page, [Your first strategy](../strategies/first-strategy.md) the worked port.

One rule differs from kScript: orders are placed in `finalize()` only, and the getters read the position after the bar's fills. A watch's money step is the other lane, for a rule over a published output rather than a strategy in the file.
