Skip to content
Algo Trade Analytics Docs

log.error() - Pine Script Function

Converts the formatting string and value(s) into a formatted string, and sends the result to the “Pine logs” menu tagged with the “error” debug level.

log.error(message) → void
NameTypeDescription
messageseries stringLog message.

The formatted string.

  • 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.
//@version=6
strategy("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 > 10
log.warning("{0}
positions opened in the same direction in a row. Try adjusting `bracketTickSizeInput`", strategy.opentrades)
last10Perc = strategy.initial_capital / 10 > strategy.equity
if (last10Perc and not last10Perc[1])
log.error("The strategy has lost 90% of the initial capital!")