SutraLipi docs grammar v1

Logging

log(...) emits a diagnostic line from your strategy — useful for tracing why a condition fired, printing a value, or leaving an audit trail of decisions. It takes one or more comma-separated expressions, evaluates each, and joins them with a single space into one message.

Syntax

Shape: log(<expr> [, <expr> ...]);. Each argument can be any expression — a string, a number, a variable, or a mix. At least one argument is required.

log("Strategy started");

// multiple arguments are space-joined into one line
float ltp = Close(nifty, M5, 0);
log("Breakout above 19500, ltp =", ltp);   // → Breakout above 19500, ltp = 19520.5

Arguments are joined with a single space. The commas inside a string literal are just text; the argument separators only add a space between parts. To place a comma between two values, write it into a string: log("ltp =", ltp, ", vol =", volume);.

Where the output goes

The destination is chosen automatically by how the strategy is running — the same log() call works everywhere:

  • Backtest — the line is streamed to the frontend and shown in the run's log output, alongside the timestamp of the simulated candle.
  • Paper & live trading — the line is saved to the database against the running execution, so it can be reviewed later.

Example

onTick {
    float ltp = Close(nifty, M5, 0);
    if (ltp > 19500) {
        log("Entry signal at", ltp);
        OrderSend(nifty, BUY, 50, 0, 0, 0, INTRADAY, DAY, "entry");
    }
}

A log() inside onTick runs on every tick. Guard high-frequency logging behind a condition so a long backtest isn't flooded with output.

Ready to run this? Build and backtest strategies in the SutraLipi algo trading platform — no-code builder, tick-level backtesting and one-click live execution. Browse all documentation topics.

Code copied — paste it into the editor with Ctrl+V.