OPEN-SOURCE SCRIPT

MES Position Sizing Estimator

Description and Use:
Here is an indicator which aims to help all Micro-ES futures traders who struggle with risk management! I created this indicator designed as a general guideline to help short term traders (designed for 1 minute candles) determine how many contracts to trade on the MES for their desired profit target.

To use the indicator, simply go to MES on the 1 minute timeframe, apply the indicator, and enter your Holding Period (how long you want to have your position open for), Value Per Tick
(usually 1.25 for MES since one point is $5) and your target PnL for the trade in the inputs tab.

It will then show in a table the recommended position sizing, as well as the estimated price change for your holding period. Additionally, there are two plotted lines also showing the position sizing and estimated price change historically.

How the indicator works
On the technical level, I made calculations for this indicator using Python. I downloaded 82 days of 1 minute OHLC data from TradingView, and then ran regression (log-transformed linear regression specifically) to calculate how the average price change in MES futures scales with the amount of time a position is held for, and then ran these regressions for every hour of the day. I then copied the equations from those regressions into Pinescript, and used the assumption that:
position size = target PnL / (estimated price change for time * tick value)

Therefore, Choosing the number of contracts to trade position sizing for Micro E-mini S&P 500 Futures (MES) based on time of day, holding period, and tick value. This tool leverages historical volatility patterns and log-transformed linear regression models to provide precise recommendations tailored to your trading strategy.

If you want to check out how the regression code worked in python, it is all open source and available on my Github repository for it.

Notes:
The script assumes a log-normal distribution of price movements and is intended as an educational tool to aid in risk management.
It is not a standalone trading system and should be used in conjunction with other trading strategies and risk assessments.
Past performance is not indicative of future results, and traders should exercise caution and adjust their strategies based on personal risk tolerance.
This script is open-source and available for use and modification by the TradingView community. It aims to provide a valuable resource for traders seeking to enhance their risk management practices through data-driven insights.
educationalPine utilitiesPortfolio management

Açık kaynak kodlu komut dosyası

Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının yazarı komut dosyasını açık kaynak olarak yayınlamıştır, böylece yatırımcılar betiği anlayabilir ve doğrulayabilir. Yazar çok yaşa! Ücretsiz olarak kullanabilirsiniz, ancak bu kodun yayında yeniden kullanımı Ev kurallarına tabidir. Bir grafikte kullanmak için favorilere ekleyebilirsiniz.

Bu komut dosyasını bir grafikte kullanmak ister misiniz?

Feragatname