PINE LIBRARY
업데이트됨 TradeManagement

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.
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
Calculates a take-profit price using a percentage.
You can specify whether the trade is long or short.
Calculates a stop-loss price using a percentage.
You can specify whether the trade is long or short.
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.
Calculates the position quantity based on:
Entry price
Stop-loss price
Maximum monetary risk
The calculation uses TradingView's symbol-specific syminfo.pointvalue.
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.
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.
릴리즈 노트
v2Removed:
positionSizeByRiskQuantity(entryPrice, slPrice, riskQuantity)
Calculates position size based on risk per unit/contract.
Note : One Useless function removed
파인 라이브러리
트레이딩뷰의 진정한 정신에 따라, 작성자는 이 파인 코드를 오픈소스 라이브러리로 게시하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 경의를 표합니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈소스 게시물에서 사용할 수 있지만, 이 코드의 게시물 내 재사용은 하우스 룰에 따라 규제됩니다.
ChartTrader-X
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
파인 라이브러리
트레이딩뷰의 진정한 정신에 따라, 작성자는 이 파인 코드를 오픈소스 라이브러리로 게시하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 경의를 표합니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈소스 게시물에서 사용할 수 있지만, 이 코드의 게시물 내 재사용은 하우스 룰에 따라 규제됩니다.
ChartTrader-X
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.