BillionaireLau

GenericTrading

BillionaireLau Updated   
Library "GenericTrading"

This library aims to collect rare but useful operations for

get_most_recent_long_or_short_position_closed_index() : returns most recent long/short closed bar index.
get_most_recent_long_or_short_position_open_index() : returns most recent long/short closed bar index.

These two functions designed to help to speed up the coding for strategies that contains "re-enter" logic.

These two functions also could applies in the situations where time-count is needed in your condition.
Release Notes:
v2

Added:
timeSinceLastEntry()

avgBarsInTrade()

avgGrossProfit()

avgOpenPositionPrice()

avgProfitInPercent()

avgTradeDuration()

maxTradeDrawDown()

maxTradeRunUp()

tradeOpenPLGross()

tradeOpenPL()
Pine library

In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House Rules.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this library?

Copy the following line and paste it in your script.