strategy.opentrades.entry_time() - Pine Script Function
strategy.opentrades.entry_time()
Section titled “strategy.opentrades.entry_time()”Overview
Section titled “Overview”Returns the UNIX time of the open trade’s entry, expressed in milliseconds.
Syntax
Section titled “Syntax”strategy.opentrades.entry_time(trade_num) → series intParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| trade_num | series int | The trade number of the open trade. The number of the first trade is zero. |
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6strategy("strategy.opentrades.entry_time Example")// Strategy calls to enter long trades every 15 bars and exit long trades every 20 bars.if bar_index % 15 == 0strategy.entry("Long", strategy.long)if bar_index % 20 == 0strategy.close("Long")// Calculates duration in milliseconds since the last position was opened.timeSinceLastEntry()=> strategy.opentrades > 0 ? (time - strategy.opentrades.entry_time(strategy.opentrades - 1)) : naplot(timeSinceLastEntry() / 1000 * 60 * 60 * 24, "Days since last entry")