serkany88

Strategy PnL Library

Library "Strategy_PnL_Library"
TODO: This is a library that helps you learn current pnl of open position and use it to create your own dynamic take profit or stop loss rules based on current level of your profit. It should only be used with strategies.

inTrade()
  inTrade: Checks if a position is currently open.
  Returns: bool: true for yes, false for no.

notInTrade()
  inTrade: Checks if a position is currently open. Interchangeable with inTrade but just here for simple semantics.
  Returns: bool: true for yes, false for no.

pnl()
  pnl: Calculates current profit or loss of position after the commission. If the strategy is not in trade it will always return na.
  Returns: float: Current Profit or Loss of position, positive values for profit, negative values for loss.

entryBars()
  entryBars: Checks how many bars it's been since the entry of the position.
  Returns: int: Returns a int of strategy entry bars back. Minimum value is always corrected to 1 to avoid lookback errors.

pnlvelocity()
  pnlvelocity: Calculates the velocity of pnl by following the change in open profit compared to previous bar. If the strategy is not in trade it will always return na.
  Returns: float: Returns a float value of pnl velocity.

pnlacc()
  pnlacc: Calculates the acceleration of pnl by following the change in profit velocity compared to previous bar. If the strategy is not in trade it will always return na.
  Returns: float: Returns a float value of pnl acceleration.

pnljerk()
  pnljerk: Calculates the jerk of pnl by following the change in profit acceleration compared to previous bar. If the strategy is not in trade it will always return na.
  Returns: float: Returns a float value of pnl jerk.

pnlhigh()
  pnlhigh: Calculates the highest value the pnl has reached since the start of the current position. If the strategy is not in trade it will always return na.
  Returns: float: Returns a float highest value the pnl has reached.

pnllow()
  pnllow: Calculates the lowest value the pnl has reached since the start of the current position. If the strategy is not in trade it will always return na.
  Returns: float: Returns a float lowest value the pnl has reached.

pnldev()
  pnldev: Calculates the deviance of the pnl since the start of the current position. If the strategy is not in trade it will always return na.
  Returns: float: Returns a float deviance value of the pnl.

pnlvar()
  pnlvar: Calculates the variance value of the pnl since the start of the current position. If the strategy is not in trade it will always return na.
  Returns: float: Returns a float variance value of the pnl.

pnlstdev()
  pnlstdev: Calculates the stdev value of the pnl since the start of the current position. If the strategy is not in trade it will always return na.
  Returns: float: Returns a float stdev value of the pnl.

pnlmedian()
  pnlmedian: Calculates the median value of the pnl since the start of the current position. If the strategy is not in trade it will always return na.
  Returns: float: Returns a float median value of the pnl.

One does not simply win every trade.
Thư viện Pine

Với tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này như một thư viện mã nguồn mở để các lập trình viên Pine khác từ cộng đồng của chúng tôi có thể sử dụng lại nó. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này một cách riêng tư hoặc trong các ấn phẩm mã nguồn mở khác, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy chung.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng thư viện này?

Sao chép văn bản vào khay nhớ tạm và dán nó vào tập lệnh của bạn.