strategy.closedtrades.entry_comment() - Pine Script Function
strategy.closedtrades.entry_comment()
Section titled “strategy.closedtrades.entry_comment()”Overview
Section titled “Overview”Returns the comment message of the closed trade’s entry, or na if there is no entry with this trade_num.
Syntax
Section titled “Syntax”strategy.closedtrades.entry_comment(trade_num) → series stringParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| trade_num | series int | The trade number of the closed trade. The number of the first trade is zero. |
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6strategy("`strategy.closedtrades.entry_comment()` Example", overlay = true)stopPrice = open * 1.01longCondition = ta.crossover(ta.sma(close, 14), ta.sma(close, 28))if (longCondition)strategy.entry("Long", strategy.long, stop = stopPrice, comment = str.tostring(stopPrice, "#.####"))strategy.exit("EXIT", trail_points = 1000, trail_offset = 0)var testTable = table.new(position.top_right, 1, 3, color.orange, border_width = 1)if barstate.islastconfirmedhistory or barstate.isrealtimetable.cell(testTable, 0, 0, 'Last closed trade:')table.cell(testTable, 0, 1, "Order stop price value: " + strategy.closedtrades.entry_comment(strategy.closedtrades - 1))table.cell(testTable, 0, 2, "Actual Entry Price: " + str.tostring(strategy.closedtrades.entry_price(strategy.closedtrades - 1)))