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.
Dans le plus pur esprit TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par nos Règles. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.