The comment attached to the order that opened a closed trade.
strategy.closedtrades.entry_comment(trade_num) returns the comment argument of the entry order. Use it to record why you entered, for example the signal name or the value of an indicator, and read it back when you analyse trades.
Syntax
strategy.closedtrades.entry_comment(trade_num: series int) -> series stringArguments
| Name | Type | Default | Description |
|---|---|---|---|
| trade_num | series int | required | Zero-based index of the closed trade. 0 is the first trade the strategy closed and strategy.closedtrades - 1 is the most recent. |
Returns
series string: The comment text given to the entry order, an empty string when none was given. na when the trade does not exist.
Remarks
- Returns na when trade_num is negative, is not below
strategy.closedtrades, or points at a trade that has dropped out of the history (seestrategy.closedtrades.first_index).
Example
//@version=6
strategy("Entry comment", overlay = true)
if ta.crossover(ta.sma(close, 10), ta.sma(close, 30))
strategy.entry("Long", strategy.long, comment = "SMA cross")
if ta.crossunder(ta.sma(close, 10), ta.sma(close, 30))
strategy.close("Long")
if barstate.islast and strategy.closedtrades > 0
label.new(bar_index, high, strategy.closedtrades.entry_comment(strategy.closedtrades - 1))See also
strategy.closedtrades.exit_commentstrategy.closedtrades.entry_idstrategy.opentrades.entry_commentstrategy.entry
Runs on Sidechair