Position Size for ATR Trailing Stop
Sep 4, 2018

The Position Size for ATR Trailing Stop tool calculates the optimal quantity for long and short positions based on volatility-adjusted stop-loss levels. It integrates Average True Range (ATR) and wick protection to determine trade size while adhering to a specific risk percentage of account equity.
Usage
The Usage section describes how the script can be used, examples should be provided in this section. This section also focuses on how main settings affect the indicator interpretation and output.
The indicator is designed to be used alongside an ATR Trailing Stop strategy to automate risk management calculations. Users can input their total account equity and the percentage of that equity they wish to risk per trade. The tool then outputs the recommended position size for both long and short scenarios.
For example, if a trader enters a long position at the current market price, the script calculates the distance between the entry and the dynamic ATR-based lower band. By factoring in exchange fees and account currency, it provides the exact position size needed to ensure that hitting the stop loss results in a loss no greater than the defined risk percentage.
Details
The script executes its calculations by first determining a trailing stop level using a combination of ATR and price wicks. It calculates "Wick Protection" by looking at the average or maximum wick length over a specific period, which adds an extra buffer to the standard ATR multiplier. This helps prevent premature stop-outs during high-volatility spikes.
The position size formula incorporates the following:
- Distance to Stop: The percentage difference between the entry price and the calculated ATR trailing stop.
- Risk Amount: The monetary value derived from the equity and risk percentage settings.
- Currency Conversion: The script handles conversions between BTC and USD for both account equity and asset pricing, ensuring accurate sizing across different trading pairs.
- Fee Inclusion: It factors in the combined buy and sell fee percentage to provide a more precise net risk assessment.
Settings
- ATR Period: Defines the lookback period for the Average True Range calculation.
- ATR Multiplier: Sets the sensitivity of the trailing stop by multiplying the ATR value.
- #Periods of Wick Protection: The lookback period used to calculate the wick buffer.
- Max [1] or Avg Wick Protection [0]: Switches between using the maximum wick length or the average wick length for the stop-loss buffer.
- Equity on Account: The total balance of the trading account.
- Equity Currency [0=BTC,1=USD]: Sets the denomination of the account equity.
- Price Currency [0=BTC,1=USD]: Sets the denomination of the asset price.
- Risk Percentage of Equity: The percentage of total equity to be risked on a single trade.
- Manual (Average) Entry at: Allows users to override the current price with a specific entry price for calculations.
- Manual Stop at: Allows users to override the ATR trailing stop with a specific price level.
- Fee Percentage for Combined Buy&Sell: The total percentage cost of transaction fees.
- BTCUSD Symbol: The ticker used to fetch BTC price data for currency conversions.
FAQ
How do I determine which position size to follow? The indicator plots two values: "Long Size" and "Short Size." Use the "Long Size" value when looking for buying opportunities and the "Short Size" when looking to sell or short.
Why does the position size change every bar? Since the ATR and wick values fluctuate with price action, the distance to the trailing stop changes, requiring the position size to adjust to maintain the same risk percentage.
How can I get access to the Position Size for ATR Trailing Stop? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.
Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.
As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.
Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.
Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.
This does not represent our full Disclaimer. Please read our full disclaimer.
© 2026 LuxAlgo Global, LLC.

