All indicators

Position Size for ATR Trailing Stop

Sep 4, 2018

Static chart image
Money ManagementTrailing-StopVolatility

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.

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.