PINE LIBRARY
업데이트됨

TradeManagement

371
TradeManagement is a Pine Script® library designed to simplify common trade-management and position-sizing calculations in TradingView strategies.

The library provides reusable functions for calculating:
Take-profit prices
Stop-loss prices
Risk/reward-based take-profit prices
Position size based on monetary risk
Position size based on risk per unit/contract
Current strategy entry price

Features
Pine Script®

Calculates a take-profit price using a percentage.
You can specify whether the trade is long or short.

Pine Script®

Calculates a stop-loss price using a percentage.
You can specify whether the trade is long or short.

Pine Script®

Calculates a take-profit price based on the distance between the entry price and stop-loss price, using a selected risk/reward multiplier.
For example, you can use a 2 multiplier for a 1:2 risk/reward target.

Pine Script®

Calculates the position quantity based on:
Entry price
Stop-loss price
Maximum monetary risk
The calculation uses TradingView's symbol-specific syminfo.pointvalue.

Pine Script®

Calculates the position quantity based on:
Entry price
Stop-loss price
Risk amount per unit/contract
Use this when you want to specify risk per contract (e.g., "Risk 0.01 per contract") rather than total monetary risk.

Pine Script®

Returns the current strategy's average entry price when a position is open.
This allows you to keep your strategy code clean while using the same trade-management functions across multiple strategies.

Important Note About Position Risk
The positionSize() function calculates the position quantity based on the specified monetary risk. However, the final risk may not always exactly match the risk amount entered.
This is because some markets or trading environments only allow specific quantity increments, such as whole-number quantities:
1, 2, 3, ...
For example, you may enter $5 as your maximum intended risk, but the calculated position size could result in an actual risk of $3.79.
This happens because the required position size might be something like 1.3, but the market or broker may only allow a quantity such as 1 or 2.
Therefore, the risk input should be considered the maximum intended risk, while the actual risk depends on the quantity precision or increment supported by the specific symbol and trading environment.

Strategy Compatibility
This library is intended primarily for use with TradingView strategies.
The position-sizing and entry-price functions rely on TradingView strategy information and symbol-specific properties.

Risk Disclaimer
This library provides calculation tools and does not guarantee a specific trading result or risk outcome.
Always verify the calculated position size, stop-loss distance, quantity rules, and actual monetary risk for the specific market, broker, or exchange before using the calculations in live trading.
릴리즈 노트
v2

Removed:
positionSizeByRiskQuantity(entryPrice, slPrice, riskQuantity)
  Calculates position size based on risk per unit/contract.


Note : One Useless function removed

면책사항

해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.