SHAD helperDisplays lines and labels for prices following the SHAD strategy.
SHAD strategy consists in selling half the position every time price doubles, thus this indicator displays values for x2, x4, x8 and x16 of current closing price.
You can also see "/2" (-50%) and "/4 " (-75%) values.
You can edit display colors and labels text size in the indicator's settings
Portfolio management
D-VaR position sizingThe D-VaR position sizing method was created by David Varadi. It's based on the concept of Value at Risk (VaR) - a widely used measure of the risk of loss in a portfolio based on the statistical analysis of historical price trends and volatilities. You can set the Percent Risk between 1 (lower) and 1.5 (higher); as well as, cap the % of Equity used in the position. The indicator plots the % of equity recommended based on the parameters you set.
Abz BTC InvestorInvestor indicator:
This indicator is intended to be used on a chart showing Bitcoin's historical price action. By viewing years of Bitcoin's history, it's possible to better see Bitcoin's current price within a long term context of the price rage.
Purpose and possible usage:
I built the indicator to make it easier for me and for friends and family to make better informed decisions about our Bitcoin investments. The indicator shows the historic range of the asset and indicates where Bitcoin is oversold (below the bottom line) and overbought (above the top purple line):
- Above the top purple line, I'll look to take some profits or consider hedging to protect my long term position's growth
- Below the bottom purple line, I'll look to dollar cost average into a long term position
I think the idea for this came from idea listening to the YouTuber Birb talking about how well Bitcoin tracked between the 200 day moving average (bottom navy moving average) and 5x that value (top moving average).
Hope you find it useful.
Best wishes,
Abzorba
Period Dollar Cost Average BacktesterHere is a simple script to calculate the profits and other dollar cost average strategy statistics. This strategy was created to avoid asset price volatility, so the pump and dump scheme does not affect the portfolio. By dividing the investment amount into periods, the investor doesn’t need to analyze the market, fundamental analysis, or anything. The goal is to increase the asset holdings and avoid fast and robust price movements.
This indicator has some configurations.
Amount to buy: the amount to buy at each time
Broker fee %: the fee percentage that the broker has for spot trade
Frequency: the frequency of the investments. Example: 1 Day means that every day, it will buy an amount of the asset
Starting Date: when the indicator will start the investment simulation
Ending Date: when the indicator will end the investment simulation
InfoCell With/Height: it relates to the panel for view purposes. Change the values to fit better on your screen.
This indicator has three lines:
Total Invested (green): total amount invested at the end of the period
Total Net Profit (pink): total profit by converting the amount of the asset bought at the latest closing price
Holding Profits (yellow): the amount that would be in the portfolio if the investor had invested all the capital in a signal trade at the beginning of the period.
The statistics panel has some information to help you understand buying the asset in one or more trades. So, besides those three lines that were mentioned above, here are the other statistics:
Entry Price: The price of the asset when the first investment was made
Gross Profit: Total amount of profit, not excluding the losses
Gross Losses: Total amount of losses, not excluding the profits
Profit Factor: The Gross Profit divided by the Gross Loss. A value above 1 means it’s profitable.
Profit/Trades: Net profit per trade. This includes the broker fees.
Recovery Factor: The Net profit divided by the relative drawdown. The higher the recovery factor, the faster the recovery of a loss
Total Asset Bought: The amount of the asset that was bought at the end of the investment plan
Absolute Drawdown: The total amount of losses that made the account balance go below its initial value
Relative Drawdown: The max drawdown that occurred, no matter the account balance amount
Total Trades: number of times the investment was made in the selected period
Total Fee: total Fee that was spent on the total investment
Total Winning Trades: the total amount of winning trades. A trade is considered a winner if the net profit is up compared with the latest investment.
Total Losing Trades: the total amount of losing trades. A trade is considered a loser if the net profit is down compared to the latest investment.
Max consecutive wins: the max amount of consecutive winning trades
Max consecutive losses: the max amount of consecutive losing trades
The chart above uses the default configuration of the indicator. Placed on the BTCUSD market, taking the time range of January 1st, 2018 to January 1st, 2022, 4 years. Buying a BTC amount with 10 USDT every day in that period would generate a more than 500% profit. Compared to the profit amount by just holding the count, which was close to 350% profit, the dollar cost average by period would be much more profitable.
Smart RebalanceThis script is based on the portfolio rebalancing strategy. It's designed to work with cryptocurrencies, but it can work with any market.
How portfolio rebalance works?
Let's assume your initial capital is $1000, and you want to distribute it into 4 coins. This script takes the USDT as the stable coin for the initial money, so in case you want other currency, the pairs must be with that fiat as the quote.
Following our example, you would take BTC, ETH, BNB, and FTT. After selecting the coins, it's time to choose how much allocation is on each. Let's put 25% on each. This way, $250 of our capital on each coin.
After selecting the coins and their allocation, you choose the price change ratio for rebalancing. Let's use 1%. Next, you start to watch the markets. The first thing that happens, following our example, is the BTCUSDT price moving 1% up.
That amount hit the ratio of 1% for the rebalance. Hence, you sell 1% of BTC for USDT and redistribute to the other coins, buying 0.25% of each currency to rebalance the portfolio.
Next, ETHUSDT goes 1% down, time to rebalance again. This time, you need to take 0.33% of each other coin and buy ETH, so this way, it's all divided as the chosen allocation.
Why use rebalancing?
Looks easy, right? It is, but very time demanding. Demands even more if you raise the number of coins you want to distribute. Having a system to do that automatically is a must to work efficiently. Rebalancing spreads the risk among multiple currencies. This way, you earn small when it goes up, but you lose small when it goes down.
What this script helps with portfolio rebalance?
This indicator will not buy/sell for you but will help you choose the best markets for your rebalancing. Which coin will work best in that period? Do I need to have more than 8 coins? How much must be my ratio? Those questions you can answer using this indicator.
What this script has?
Start and End dates
The script will work for a certain period. All calculations will be done in that period.
Coin Ratio %
The amount of price movement of each asset that will be used to calculate the rebalancing
Initial Capital and Broker Fee
The amount of capital to be used on the rebalancing and the broker fee you want to use the strategy. The cost will be applied on every trade, buying or selling the coins.
Assets, allocations, and colors
It's possible to select from 2 to 10 assets to be used on the portfolio. Each purchase must have the allocation %. Suppose the sum of the allocations is different from 100%. In that case, a warning message will appear on the chart instead of the statistics.
Panel and tooltips
There is a panel with a summary of the results
Set allocations automatically
There is an option to make the indicator use the daily asset volume from the day before to determine the allocation percentage of each asset. This option is better if you are unsure how much allocation you want to use on each coin.
Use this indicator as a backtest for your rebalancing strategy. The selected market on the chart will not affect the calculation on this indicator, but the time frame will. The higher the time frame, the higher the coin ratio % must be.
About the code
The code is written to use arrays to store the values of each asset, making the calculations on each candle inside the time range. The for-loops are used to reduce the code length and make it easy to change the analysis of all assets. Finally, the script has some comments on the code.
Portfolio IndexPortfolio Index Indicator
Compare a selected asset against a 3 assets portfolio.
Inputs :
- Equity : Default 10000, Initial capital for the portfolio
- %Holding : % of Holding for each Portfolio Element
- Asset in the chart as compared asset
Output :
- Delta between selected asset and portfolio
RedK Portfolio Tracker [Table Version]RedK Portfolio Tracker is a simple tool that enables a trader to monitor and track a portfolio of up to 10 holdings (+ free cash) in real time - directly on the chart
Now that we have tables in Pine, this is a table version of my previously published Portfolio Tracker
- The table works better in visualizing the various table elements (title row, column labels..etc), and is more flexible in allowing color coding of gain/loss. for many traders, myself included, these simple visual signals are valuable in helping timely trading decisions.
I'll come back and improve this script as i'm really enjoying the ability to track things this way - if you liked this and want to receive the updates, please flag / favorite it below and you'll get notified when i publish new versions.
Some new features for the table version:
- ability to change default color of various table elements (text, default background, title background, gain/loss color, border..etc)
- ability to change the text size to suit your monitor and visual preference
- ability to change table position
The "portfolio-specific" inputs are similar to the previous version - we get the ability to enter up to 10 positions, entry price and qty, then also add the free cash
- also a change from prior version, this table will plot by default on the price chart, but will have no scale - the portfolio ploy itself will also show (blue/orange stepping line) but the PnL plot will be hidden by default -- how we plot the portfolio & P/L is possibly one of the areas for improvements for next versions - also thinking of other adding valuable data i track in my own trading, like the quarterly dividends for the held positions .. we'll see - this is just a start
hope some will find this useful. feel free to comment.
Tabular Portfolio by CJS V1This is a useful indicator that sits on top of the charts, in the right hand bottom corner and shows the current price, profit or loss in value and percent of upto 20 scrips fed in, in a Tabular form using tables feature.
Allows to mark a/c id also if you have multiple broker or individual accounts.
Colors are customisable.
Stocks get updated no matter what is your current selected scrip.
Gives total investment and total PnL also in percent.
Useful to monitor your portfolio status in once screen and while you are looking at charts.
Give feedback for improvement or issues, if any.
Credits to RedKTrader from where the idea was picked up.
Move visual order to front, if the charts and other indicators overlap the table view.
Risk Position Sizing tool using Coefficient of VariationA way to manage portfolio risk using relative standard deviation, also known as coefficient of variation. This tool tells you how much of each stock in shares and in value to buy adjusted for their volatility risk for a given starting account capital. A problem many people have is how to diversify an account and adjusting it for the risk involved in each equity. Many would put in an equal amount of capital value into each share but is it really equal if some equities have more risk than others? A solution is to adjust the portfolio by giving less weight to those that are more volatile or risky. It's done by using a starting percent of the account, preferably a small percent of it, and buying up shares with that same amount for each equity. Each equity will also be divided by the COV to risk adjust the portfolio by giving less weight to the more volatile stocks. This is done until as much of the initial capital in the account as possible is spent.
COV is how far away the price is from the mean or average. The further the price is from the mean the more risk or volatility there is. It uses standard deviation in its calculation. The problem with SD and ATR is that they are not relative to the past or to other equities to compare to. An application where COV can be used is risk portfolio management formulas. This does not take into account correlation or other equation parts in some portfolio management formulas but only the risk or volatility, the default volatility length is mostly arbitrary, and the lower risk stocks may end up being the slowest in performance.
The text label will show how many shares will be bought and how much value each equity will have. At the end it will show the initial capital that was started off with, the total shares bought, the total value of all the shares, and the amount of capital left over. If the sources are not blank then they will be used, to blank them you will need to reset the settings to default otherwise they might still be read. If you want to add more than the given 10 equity spaces to the portfolio then you will need to add in the code manually and add it to the chart. The denominator is perhaps the important part in these types of risk position sizing tools, you can change to other things such as risk-reward ratio instead of volatility or change the volatility type, etc.
RedK_Portfolio Tracker v2: few enhancements and display optionsThis is an update for the PTracker v1 that I published couple of days ago. wanted to publish this as a separate script to get a chance to show how the new Portfolio Summary Infobox can be displayed on the price chart as an option. In my opinion, that info box is the most important element in this tool and that's the piece i was most looking for.
quick note here: you can track your portfolio (if not so many positions) by entering something like (without the brackets) in TradingView's chart symbol area - TradingView will resolve these symbols and chart the total -- there's a nice post by our friend @boji1 about this in a lot more details - however, that wouldn't show the stats that i need to look at to track my portfolio on daily basis.
i also made couple of other enhancements, like adding the ability to include "free cash" in the portfolio - While this free cash value will impact the Total P/L and P/L %, as part of the overall portfolio (and the denominator), it will not impact the "cost of positions" or the (current) "value of positions" -- also "Cash" will not count towards the total 10 positions that we can track with this tool.
Using Portfolio Tracker as a floating panel on the price chart
====================================================
By default, when the Portfolio Tracker is added to the chart, it will occupy its own lower panel like the picture above.
if your charts are already busy (like mine :)) - you most probably already have a couple of lower studies and it's crowded there.
in this case, you can use the Object Tree tool after adding the PTracker, to drag it onto the price panel, or you can also do that by right-clicking on the infobox and choose to move up to the price panel.
when you do that, remember to also use the Style settings of PTracker to hide both Portfolio and PnL plots, and choose Scale = no scale - this way you get the infobox to work like a floating panel on the price chart
here's a screenshot that shows this scenario - also shows how the infobox color can be easily changed from the PTracker settings to suit your chart background and for best visibility
i hope this is useful in your trading - i look forward to @TradingView team surprising us with a real portfolio tracking capability soon :)
good luck.
Simple Portfolio TrackerThis is just a simple portfolio tracker that i started to play around with - i'm sure there are smarter ways to do this, but i chose the simpler way :) -- please feel free to use this, or consider it as a starting point to your own indicator.
i will come back later and add some more stuff once i get time. for example, show the total value, recent change, P&L % ..etc
So the simple idea is to track a portfolio of few positions and watch how the total portfolio and the PnL changes over time as the price of the individual holdings move up and down. it can be added to any chart.
The code is currently set to track 5 positions - settings allow to enter if the positions is used or not, symbol, amount and cost price..
** note: more positions can be added by editing the code and copying and pasting the marked "position block" that contains the input statements and the calculations, then changing/replacing the position identifier (_1, _2, ..etc) in all variables with new number..
--- don't forget to add these extra positions you insert in the code to the formula lines that calculate the totals
i tried to make this as easy as possible in the code. the code includes a sample portfolio as default values just to help "demo" how this works
the input is made easy, thanks to the recent addition of the "inline" feature in the input() statement
i don't know if some traders will find this useful ?? or if more about how to use it is needed.. let me know in the comments.. as i mentioned, i was just playing with the idea over the weekend so didn't really put a lot of work into it.
Credits and thanks to @boji1 for inspiring this :)
Portfolio and Risk Management: Gold Based Net Growth CoefficientHello, if our topic is stocks, whatever signal we get, we have to divide and reduce the risk.
Apart from the risk, we need inflation-free figures to detect a clear growth.
Gold is one of the most successful tools to beat inflation in this regard in the historical context.
When the economy is good, we have to beat both commodities and inflation.
For this purpose, I found it appropriate to develop a net growth factor free from gold growth.
Investors need several stocks with a high growth rate and as much risk-free as possible.
Personally, I think that the science of portfolio and risk management will last a lifetime and should continue.
I think this subject is a research and development subject.(R & D)
My research and publications on this matter will continue publicly.
I wish everyone a good day.
NOTE : You can determine the return in the time period you want to look back by adjusting the period in the rate you want from the menu.
The standard value is 200 days. (1 year)
Order Size CalculatorScript to calculate the amount of stocks for of an order in relation to depot size (money), risk awareness, profit target and ATR
Order Size CalculatorThis script calculates the amount of stocks in a trade based on risk awareness.
The risk awarness is part of portfolio management and the book "sustainable & successfull trading" by Faik Giese.
Input is depot size (cash and stocks), risk per depot position, max. Stop-Loss and ATR.