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.
Dengan semangat TradingView yang sesungguhnya, penulis skrip ini telah menerbitkannya sebagai sumber terbuka, sehingga para trader dapat memahami dan memverifikasinya. Hormat untuk penulisnya! Anda dapat menggunakannya secara gratis, namun penggunaan kembali kode ini dalam publikasi diatur oleh Tata Tertib. Anda dapat memfavoritkannya untuk digunakan pada chart
Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.