log.info() - Pine Script Function
log.info()
Section titled “log.info()”Overview
Section titled “Overview”Converts the formatting string and value(s) into a formatted string, and sends the result to the “Pine logs” menu tagged with the “info” debug level.
Syntax
Section titled “Syntax”log.info(message) → voidParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| message | series string | Log message. |
Returns
Section titled “Returns”The formatted string.
Remarks
Section titled “Remarks”- Any curly braces within an unquoted pattern must be balanced. For example, “ab {0} de” and “ab ’}’ de” are valid patterns, but “ab {0’}’ de”, “ab } de” and ””{”” are not.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6strategy("My strategy", overlay = true, process_orders_on_close = true)bracketTickSizeInput = input.int(1000, "Stoploss/Take-Profit distance (in ticks)")longCondition = ta.crossover(ta.sma(close, 14), ta.sma(close, 28))if (longCondition)limitLevel = close * 1.01 log.info("Long limit order has been placed at {0}", limitLevel)strategy.order("My Long Entry Id", strategy.long, limit = limitLevel)log.info("Exit orders have been placed: Take-profit at {0}, Stop-loss at {1}", close, limitLevel)strategy.exit("Exit", "My Long Entry Id", profit = bracketTickSizeInput, loss = bracketTickSizeInput)if strategy.opentrades > 10log.warning("{0}positions opened in the same direction in a row. Try adjusting `bracketTickSizeInput`", strategy.opentrades)last10Perc = strategy.initial_capital / 10 > strategy.equityif (last10Perc and not last10Perc[1])log.error("The strategy has lost 90% of the initial capital!")