strategy.closedtrades.exit_time() - Pine Script Function
strategy.closedtrades.exit_time()
Section titled “strategy.closedtrades.exit_time()”Overview
Section titled “Overview”Returns the UNIX time of the closed trade’s exit, expressed in milliseconds.
Syntax
Section titled “Syntax”strategy.closedtrades.exit_time(trade_num) → series intParameters
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”// Reopens a closed trade after X seconds.//@version=6strategy("strategy.closedtrades.exit_time Example 2")// Strategy calls to emulate a single long trade at the first bar.if bar_index == 0strategy.entry("Long", strategy.long)reopenPositionAfter(timeSec) =>if strategy.closedtrades > 0if time -strategy.closedtrades.exit_time(strategy.closedtrades - 1) >= timeSec * 1000strategy.entry("Long", strategy.long)// Reopen last closed position after 120 sec.reopenPositionAfter(120)if ta.change(strategy.opentrades) != 0strategy.exit("Long", stop = low * 0.9, profit = high * 2.5)