The comment attached to the order that opened an open trade.
strategy.opentrades.entry_comment(trade_num) returns the comment argument of the entry order that created this trade.
Put the reason for the entry in the comment and show it on the chart while the trade is open.
Syntax
strategy.opentrades.entry_comment(trade_num: series int) -> series stringArguments
| Name | Type | Default | Description |
|---|---|---|---|
| trade_num | series int | required | Zero-based index of the open trade. 0 is the oldest open entry, the one a FIFO exit closes first, and strategy.opentrades - 1 is the newest. |
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 or is not below
strategy.opentrades, so guard every call with the open-trade count.
Example
//@version=6
strategy("Open reason", 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.opentrades > 0
label.new(bar_index, high, strategy.opentrades.entry_comment(0))See also
Runs on Sidechair