Lipi Reference
Lipi

Functions

strategy.closedtrades_exit_price()

For the closed trade number `trade_num`, returns the price at which the trade was closed. Trades are numbered from 0 in the order they were closed, so the most recent is `strategy.closedtrades - 1`.

Syntax

                strategy.closedtrades_exit_price(series int trade_num) → series float
              

Arguments

trade_num required series int

Return Type

series float

Example


          //@lipi=2
strategy("strategy.closedtrades_exit_price Example", overlay=true, initial_capital=10000, default_qty_type=strategy.fixed, default_qty_value=1)
if talib.crossover(close, talib.sma(close, 20)) {
    strategy.entry("Long", strategy.long)
}
if talib.crossunder(close, talib.sma(close, 20)) {
    strategy.close("Long")
}
value = strategy.closedtrades > 0 ? strategy.closedtrades_exit_price(strategy.closedtrades - 1) : na
plot(value, title="Exit Price", color=color.blue)