Position Sizing Calculator (Real-Time)█ SUMMARY
The following indicator is a Position Sizing Calculator based on Average True Range (ATR), originally developed by market technician J. Welles Wilder Jr., intended for real-time trading.
This script utilizes the user's account size, acceptable risk percentage, and a stop-loss distance based on ATR to dynamically calculate the appropriate position size for each trade in real time.
█ BACKGROUND
Developed for use on the 5-minute timeframe, this script provides traders with continuously updated, dynamic position sizes. It enables traders to instantly determine the exact number of shares and dollar amount to use for entering a trade within their acceptable risk tolerance whenever a trade opportunity arises.
This real-time position sizing tool helps traders make well-informed decisions when planning trade entries and calculating maximum stop-loss levels, ultimately enhancing risk management.
█ USER INPUTS
Trading Account Size: Total dollar value of the user's trading account.
Acceptable Risk (%): Maximum percentage of the trading account that the user is willing to risk per trade.
ATR Multiplier for Stop-Loss: Multiplier used to determine the distance of the stop-loss from the current price, based on the ATR value.
ATR Length: The length of the lookback period used to calculate the ATR value.
Welleswilder
Trading Made Easy ATR BandsAs always, this is not financial advice and use at your own risk. Trading is risky and can cost you significant sums of money if you are not careful. Make sure you always have a proper entry and exit plan that includes defining your risk before you enter a trade.
Background:
This is my take on two relatively famous indicators that paint the colour of your candles in order to help identify trend direction and smooth out market noise. The Elder Impulse System was designed by Dr . Alexander Elder in his book Come Into My Trading Room and attempts to identify the change of trends and when these trends speed up and slow down (school.stockcharts.com). The system used a 13 period EMA and a MACD histogram, and compared each of these indicators to the previous period. In short, when both the histogram and the EMA were rising, the trend was accelerating to the upside and when both were falling, accelerating to the downside. Conversely, when the indicators were not in alignment, say the MACD falling but the EMA rising, it signaled a slowing down of momentum. The downside of this indicator is that it be can rather jumpy, focusing on a short period EMA for 50% of its calculation, leaving a trader to potentially sit on the sidelines during opportune pull backs to enter winning positions, or exit early when there is still a lot of gas left in the tank.
A similar concept has been employed by John Carter and his organization, SimplerTrading, with the 10X bars indicator. However, here they use the famous Directional Movement Index (DMI) created by J. Welles Wilder as the basis for their bars (www.simplertrading.com). John Carter states that the use of this indicator can lead to getting in earlier on more, bigger, and faster setups. The downside of this indicator is the reliance on the ADX calculations to keep you out of rangebound trades. Anyone who is familiar with the DMI system understands it has unparalleled ability to identify longer term trends, but it is also quite slow, leaving the trader to miss a good portion of the initial runup due to this ADX portion that is very slow to get moving and also slow to signal exits.
In short, both of these systems are designed with one thing in mind: keeping the trader on the right side of the move --- but both suffer from the same issue but on opposite sides of the spectrum. One is too fast and the other is too slow. Ultimately, leaving profits on the table for the trader when such a situation could be avoided.
Here I present my own take on these and have made the “Trading Made Easy ATR Bands”. I name it this because trading is much easier when you trade with the prevailing trend, and this system identifies these periods quite effectively while doing a better job of handling the speed flux of most markets. The base formula uses the DMI as its main calculation and the relationship between the DMI+ and DMI- lines, respectively, like the 10X bars. While the trader can investigate these on their own to understand these more intimately, essentially the DMI+ and DMI- lines are calculating the highs and lows respectively of each bar compared to a period in the past and smoothed with the true range, a measurement of volatility . What this ultimately presents is a picture of uptrends and downtrends, where price is making consistently more highs or more lows over a period of time. Where I have modified this relative to the 10X bars is I have ignored the ADX calculations. Further, values over 25 have been discussed as “strong” momentum, in my calculations, I have sped this up to 20 to get a trader into the move earlier. Second, I have added an additional calculation based around the 21-period exponential moving average calculated against its previous output. This then, like the Elder Impulse System, has two forms of market momentum as its calculation to smooth out noise, but has the benefit of being less jumpy, like the original 10X bar system. I have added a series of exponential moving averages following the Fibonacci sequence from 8-144 as a system of dynamic support and resistance showing the sentiment of both the shorter and longer term market participants. Last, I have added a series of Keltner Channels , from 1X-4X, that encompass the 21 period EMA as a base line. The 21 EMA is a stable in all of John Carter’s work and I do believe he is correct that the market is mostly structured around this line, since it roughly approximates one month of trading data. It is not uncommon to see price expand and contract back to this line over and over again.
Trade Signals:
Strong Bullish Momentum – The system will generate a green bar when the DMI+ line is over the DMI- line, the DMI+ line is equal or greater than 20 and the 21 EMA has increased relative to its last close.
Weak Bullish Momentum – The system will generate a blue bar in several scenarios. First, when the DMI+ line is over the DMI- line but the DMI+ line is not over 20 and the EMA is equal or less than the previous close. It will also print a blue bar if either the DMI or the EMA are not aligned, such as the DMI+ is over the DMI- but not over 20 but the EMA has risen compared to the last bar. Last, it will also print a blue bar if the DMI- is over the DMI+ but the EMA is rising.
Strong Bearish Momentum – The system will generate a red bar when the DMI- line is over the DMI+ line, the DMI- line is equal or greater than 20, and the 21 EMA has fallen relative to its last close.
Weak Bearish Momentum – The system will generate an orange bar in several scenarios. First when the DMI- line is over the DMI+ line but the DMI- line is not over 20 and the EMA is equal or greater than the last bar. It will also print an orange bar if either the DMI or the EMA are not aligned, such as the DMI- is over the DMI+ but not over 20 but the EMA has fallen. Lastly, it will also print an orange bar if the DMI+ line is over the DMI- and the EMA has fallen relative to the last bar.
Uses:
1) Like the Elder Impulse System and 10X Bar systems, these should be used as trade filters only.. It is in the trader’s best interest to trade with the trends and these bars identify these periods but may not always generate the most opportune time to enter a market. For instance, trying to short a market when the market is in a phase of Strong Bullish Momentum would not be wise, and vice versa with trying to open long positions when the market is exhibiting Strong Bearish Momentum. Use multiple forms of evidence to confirm the signals shown before entering any trade and to not take these signals on their without confluence of ideas. A viable system could use the Elder Triple Screen System (for reference, see this decent write up --- www.dailyforex.com) with the Trading Made Easy Bands as your “Tide” or longer term filter, and a further trading plan to establish an entry on a short time frame pull back.
2) Interim Trend Exhaustion – Keltner channels work as moving standard deviations from the 21 EMA . 3X multipliers will encompass 99.7% of price and 4X will encompass 99.9% of price away from the 21 EMA . During a trend it would be a good idea to lock in partial profits when price reaches these outer extrema as it is very highly probable that a retracement back to the mean is approaching. While not part of the system, and not recommended to be used by this system, a mean reversion trader could in theory look for reversals at these extrema points and trade a mean reversion strategy back to the 21EMA, but is a much riskier trade with lower probability of success. A trend trader should look to enter trades when a signal is given within the 1ATR or 2ATR zone as this is when price has not really started accelerating yet and is likely to see continued momentum in that direction.
Ehlers Directional Movement Hann Window Indicator [CC]The Directional Movement Hann Window Indicator was created by John Ehlers (Stocks and Commodities Dec 2021 pgs 17-18) and this is his updated version of the classic Directional Movement indicator created by J. Welles Wilder. Ehlers uses the Hann Window Filtering after using an exponential moving average to smooth the classic directional movement indicator. This helps significantly with the lag and lack of smoothing which are both issues with the classic indicator. I have included strong buy and sell signals in addition to the normal ones so strong signals are darker in color and normal signals are lighter in color. Buy when the line turns green and sell when it turns red.
Let me know if there are any other indicators you would like to see me publish!
[MX]Moving Average - LibraryLibrary "MA_library"
OVERVIEW
This library contains moving average functions that calculate values for which they do not exist by default in PineScript
Functions
tema(source,length) : Triple Exponencial Moving Average
dema(source,length) : Double Exponencial Moving Average
wwma(source,length) : Welles Wilder Moving Average
gma(source,length) : Geometric Moving Average
Heiken Ashi Pivot Breakout Trailing StopThis is a heiken ashi pivot based trailing stop for breakout entries and exits. It's possibly related to the Swing Index System by Welles Wilder or an alternative to it that I came up with, in case determining the swings on the Accumulative Swing Index is too much of a burden. It is believed that the ASI uses the calculation of heiken ashi in its formula. This does not use the ASI as a bottom indicator in the chart but instead uses the heiken ashi bars on the top of the chart to objectively find the swing pivots . These swings pivots act as support and resistance and can be used to confirm the start of a breakout or the end of one.
Suppose you find a chart pattern or setup, such as divergence or a pennant in the RSI , a pattern on the ASI, and/or on the chart, or the end of an elliot wave , etc and want to confirm a strong breakout and ride it to the end. Many trailing stops won't be able to confirm the beginning or would last too long or not long enough to exit out of one. On an uptrend, when the price breaks below the last swing low pivot , it can confirm the end of the breakout. On a downtrend, when the price breaks above the last swing high pivot , it can confirm the end of the breakout.
This trailing stop is not meant to replace trend following ones. The swing pivots can vary yet the price can still continue at an uptrend whereas this heiken ashi pivot based trailing stop exits as soon as it goes above or below the last resistance point. These swing points can end up being too close for trend following but can work well for breakout trading. The bigger the chart pattern or breakout, the more reliable the exit signal will be in my opinion. This is an experimental idea that I came up with from trying to interpret the ASI.
Backwards price projection - few bars ahead reverse chartEver wondered what the chart would look like if it's flipped upside down and flipped horizontally into the future? The idea is that when there is a trend, a repeating pattern tends to occur. Going backwards and projecting that movement into the future can supposedly show what the future price will be.
Somehow I haven't found anyone try it like this and I am currently trying to find a way to use a reversed moving average or plot of some kind to project further ahead. TV at the moment does not allow offsets on candle plot(as far as I know) and I am only allowed a certain number of plots to go on the chart, so I put as many price moves ahead as I could to project the future price. It's a bit sloppy with all those forced plots but it gets the job done. I'll see if I can improve it with a moving average or something and possibly make a strategy out of it in the future.