OPEN-SOURCE SCRIPT

Enhanced Kelly Criterion with Risk Management

This script is a trading tool for risk management and position size calculations based on the Kelly criteria. The objective is to calculate the optimal position size for each trade based on win/loss ratio and win/loss ratio to manage your money.

Overview
Initial Funding: Starting with an initial capital of $10,000, the balance (amount of funds) of both “bullish” and “bearish” positions will increase or decrease depending on the outcome of the trade.

Risk Management: Users can set their risk tolerance from 1-100%. In addition, the maximum position size per trade is also limited at 50%, for example. This setting allows the user to limit risk.

Record of trade results: For each trade, a positive (bullish) or negative (bearish) line is determined, and wins and losses are recorded accordingly. Win/loss ratios and win/loss ratios are also calculated in real time from this data.

Win rate: Calculates the percentage of winning trades in a trade.
Win/Loss Ratio: Calculates the ratio of profit/loss between positive and negative trades.
Position sizing using the Kelly Criterion: Based on the win/loss ratio, the optimal position size to take on the next trade is calculated using the Kelly Criterion. However, this Kelly Criterion is treated with caution because of the potential for increased risk.

Controlling Risk and Position Size
Volatility adjustment using ATR (Average True Range): The script considers market volatility (range of price fluctuation) using a measure called ATR. This allows for smaller position sizes when price volatility is high, thereby reducing risk.
Position Size Limit: The maximum position size is limited so that the calculated position size does not exceed a certain range. This reduces the risk of large losses.
Display of Results
The script visually plots the final position size and amount of funds so that traders can see the changes in balance. To highlight points of change, position size expansions and contractions are shown, allowing traders to catch signs of sudden fluctuations or changes in volatility.

Suggested Improvements and Considerations
Kelly Criteria Overexposure Risk: Calculations based on the Kelly Criteria are theoretically correct, but they tend to take large positions. This can be very damaging in the event of losses. Therefore, while this script limits risk by setting a maximum position size, it is recommended that you adjust to an even more modest position size.

Data Reliability: The calculation of win/loss ratios and win/loss ratios relies on historical trade data, which can be unreliable until sufficient trade data is gathered. When trade data is scarce, calculations based on the Kelly Criteria may be overly optimistic.

Volatility considerations: Volatility adjustment using ATR is effective, but ATR alone may not be sufficient when markets fluctuate rapidly; if ATR adjustment is insufficient, additional risk mitigation techniques should be used in conjunction.

Overall, this script emphasizes risk management and optimizes position size using the Kelly criteria, but real market conditions require careful risk management with attention to overexposure.
educational

オープンソーススクリプト

TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。 お気に入りに登録してチャート上でご利用頂けます。

チャートでこのスクリプトを利用したいですか?

免責事項