Description: This indicator calculates an average trading volume per minute for the specified lookback period (default 377 bars). It then estimates a suitable position size in USD (or contracts on specific exchanges) by multiplying the average volume by a user-defined percentage (default 8%). The script discards extreme data points (top and bottom 20%) before finding the median, so it provides a more robust measure of typical volume.
How It Works: 1. Each bar’s volume is converted to a USD-based figure, either by taking volume directly (if the exchange quotes in USD) or multiplying volume by the midpoint price. 2. Values are stored in an array, which is then sorted to remove the most extreme 40% (20% from each tail). The remaining 60% is used to calculate a median. 3. You enter a position size percentage (e.g. 8%), and the script multiplies the median volume-per-minute by this percentage to get your recommended position size. 4. For certain exchanges like BitMEX/Deribit, the script adapts how it treats volume (in quotes vs. base), so it can display the final position size properly (USD or contracts). 5. The script displays the result in a small table on the chart, showing the recommended position size in USD (or, for some perpetual contracts, in contract units). If no valid data is available, it indicates “Data Invalid.”
Usage Tips: • The default Position Size Percentage is 8%. You can adjust it higher for more aggressive trading or lower for smaller exposure. • The default lookback (Average Calculation Period) is 377 bars. Experiment with different values (e.g. 200 or 500) to capture more or fewer historical bars. • On certain exchanges and symbols (e.g. BitMEX or Deribit’s “.P” pairs), the script automatically switches how it calculates volume (USD vs. coin-based). • If you see “Data Invalid,” it likely means the current symbol or timeframe lacks sufficient volume info, or you’re running it on a symbol like BTC.D.
Why This Helps: • Many traders size positions by guesswork or a fixed fraction of their account. This script instead ties position size to actual average trading volume, ensuring your position is neither too large (risk of poor fills) nor too small (wasting leverage potential). • Removing top/bottom outliers and using the median aims to give a stable volume measure—less influenced by sudden spikes or extremely quiet bars.
Feel free to tweak the inputs and experiment with different timeframes or pairs. By aligning your position size with typical market liquidity, you can potentially improve overall trade execution and manage risk more effectively.
진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.