Equity CurveAn equity curve is a graphical representation of the change in the value of a trading account over a time period. The equity curve is a direct reflection of a trading strategy's effectiveness. A consistently upward-trending equity curve indicates a successful strategy, while a flat or declining curve may signal the need for adjustment.
This indicator takes traders daily account values as a comma separated list, and creates an equity curve and simple moving average of the equity curve. This serves as a mirror reflecting the outcome of past actions and decisions, guiding traders in fine-tuning their strategies, managing risk more effectively, and ultimately striving towards a consistently profitable trading journey.
New equity values should be added to the end of the current list. A space or no space after the comma has no effect.
Importance of the Equity Curve
Strategy Evaluation: The equity curve is a direct reflection of a trading strategy's effectiveness over time. A consistently upward-trending equity curve indicates a successful strategy, while a flat or declining curve may signal the need for adjustment.
Risk Management: Monitoring the equity curve helps traders to see the impact of their risk management practices. Sudden drops in equity could highlight instances of excessive risk-taking or inadequate stop-loss settings.
Performance Benchmarks: Comparing the equity curve against benchmarks or desired performance goals allows traders to assess if they are meeting, exceeding, or falling short of their trading objectives.
Psychology: Trading is as much about psychology as it is about strategy. A visual representation of one's equity curve helps maintain discipline, encouraging adherence to a trading plan during downturns and preventing overconfidence during upswings.
Having this data visually allows traders to see which category of trader they fall into.
Unprofitable
Boom or Bust
Profitable
Statistical Data
The indicator not only plots the equity curve and moving average, but includes the option to display the highest value reached by the equity curve, the percentage difference from the peak, and performance over selected periods (All Time, YTD, QTD, MTD, WTD).
Historical Analysis
The Equity Curve Indicator is not just a tool for real-time monitoring of trading performance; it also serves as a powerful instrument for conducting historical analysis. By analyzing the equity curve in conjunction with historical market conditions, traders can identify patterns or triggers that resulted in significant gains or losses.
For example, the chart below shows the equity curve overlaid on periods of net new highs / lows. The equity curve experienced declines while the market was showing net new lows or choppy periods (represented by a red or white background), while most of the equity gains were made while net new highs were present (green background).
This retrospective analysis helps in understanding how different market conditions impact trading strategies and performance.
Trading the Equity Curve
All trading strategies produce an equity curve that has winning and losing periods. In the example above, the trader could introduce a simple rule to lighten up on long positions or move to cash during periods of net new lows.
Another simple rule could be introduced to stop trading if the equity curve falls below the moving average, until favorable market conditions return again.
This indicator is intended to be used on the daily timeframe.
Portfolioperformance
Portfolio TableA tool to manage your invested assets (stocks, crypto currencies, ...).
- Show profit of every asset as well as the total profit.
- Show/hide a bought price line on the chart if the current selected ticker is on your portfolio.
Live PnL v1.0Live P&L for multiple stocks, currencies, crypto and commodities can now be tracked for your favorite scripts, pair trading etc.
This indicator gives provision to add up to 3 stocks/futures/currency with Buy and Sell, Quantity (can be lot size or any other) and Entry Price and set as default so that every time you put back this indicator you can monitor the live Profit / Loss figure.
This indicator will help trade to evaluate and track tips/trades of experts on social media and Media platforms and check their accuracy themselves in an organized way.
Apart from paper trading a trade or multiple positions ones combined together it also gives a feeler of combined Mark to live Market Drawdowns or Profitability.
Portfolio Tracker For Stocks & CryptoThis is a portfolio tracker that will track individual, overall and daily profit/loss for up to 12 assets. You can set the size of your buys and price of your buys for accurate, up to date profit and loss data right on your chart. It works on all markets and timeframes.
HOW TO USE
Go into the indicator settings and you will see all of the available settings. The first is the ability to turn the tracker info table on or off from the chart, so it saves your portfolio info but let’s you remove it from the chart while trading. Second is the option to move the position of the info table to suit your preference.
Next we get into setting up your portfolio tickers, order size and price. Each ticker lets you set which stock/crypto you bought, then set how much you purchased and then what price you purchased them at.
Go through and set up all of your assets and then turn off any tickers that you don’t need. Once that is all done, your portfolio will be shown on the chart with all the data.
FEATURES
Top Section
The portfolio tracker has 2 sections. The top section shows each ticker in your portfolio individually with the following data:
- Ticker Name
- Weight of that asset compared to your total portfolio in %
- Current value of that position in $
- Profit or loss value from purchase price in %
- Todays change in value from yesterday’s close in %
The $ Value, PnL % and Today % will all change colors from green to red depending if they are in profit or not.
Bottom Section
The bottom section of the tracker will give you info for your portfolio as a whole. It has the following data:
- Total cost of your entire portfolio in $
- Current value of your entire portfolio in $
- Current profit or loss of your entire portfolio in $
- Current profit or loss of your entire portfolio in %
- Todays change of your entire portfolio value compared to yesterday’s close in %
The $ Value, PnL $, PnL % and Today % will all change colors from green to red depending if they are in profit or not.
Portfolio PerformanceThis indicators will help you to compute portfolio performance and display results with a stats table and a nice monthly chart.
In this script you can do following:
Compose portfolio with up to 15 instruments
Change Initial capital / date range / rebalancing period
Compare portfolio performance with a benchmark
Compute basic stats
Compute instruments contribution
Display monthly performance of portfolio and benchmark
Change style for almost everything you see on your chart
Hope it will be useful for you!
Thanks to @MUQWISHI for helping me coding it.
Disclaimer
Please remember that past performance may not be indicative of future results.
Due to various factors, including changing market conditions, the strategy may no longer perform as well as in historical backtesting.
This post and the script don’t provide any financial advice.
Portfolio SummaryThe stocks in my portfolio has very poor performance since the FED hiked the rate.
since the covid-19, i came to the stock market and buy a stock that i ever heard the name which i don't even know its fundamental.
Some stock, i bought them at the hilltop (and sell at the bottom, hehe).
Everyone is a genius in a bull market ; and now i realized i am gonna loss money.
I have to do something, so i looked for an indicator that allow me to manage my portfolio.
unfortunately, i cannot find one that fit me.
so i make this indicator.
How you can get the benefit from this indicator
This indicator will summarize the gain/loss since you bought the stock.
it also include the dividend.
So that you can see how much you gain and loss, and make a decision as you wish.
How to use it
1. Input some neccessary data like ticker/stock (up to 20 tickers, yeah i know, it is too much), share, average price which you can input manually or depend on your entry date.
2. The indicator will calculate gain/loss, dividend, % of your portfolio.
3. You can select how to display based on "Index" or "Market Value".
4. You can toggle on/off both label and table.
Disclaimer
This indicator may display inaccurate and need a lot of improvement.
pls use carefully.
if you have any suggestion, pls dont hersitate to comment below.
Enjoy.
Portfolio Performance - Effects of RebalancingFunction:
- Can be used to evaluate the performance of a portfolio containing 2 assets over a set time interval
- Shows the % return of the portfolio over the time interval defined by the user
- Includes a threshold rebalancing algorithm to show the effects that rebalancing has on the portfolio over the long term
- Created to evaluate of the performance of portfolios containing different weightings of stocks and bonds over time assuming that the user would rebalance the portfolio when asset weights crossed a threshold
Instructions:
- To be used with dividends adjustments turned on
- Add this script to a symbol. e.g. AMEX:SPY
- Click the chart to define the entry time and the exit time. i.e. the time interval
- Define the initial investment of the portfolio. Default setting is $100,000
- Define the second asset to be included in the portfolio. e.g. BATS:AGG
- The strategy comes pre-populated with a portfolio that has a weight of 80% asset 1 and 20% asset 2. i.e. 80% AMEX:SPY and 20% BATS:AGG if the symbols mentioned above were chosen
- The 7 lines show the weighted % return of each portfolio over the time period defined by the user
- Each line (except the blue) is the return based on a different rebalancing threshold. The default settings are 1%, 2.5%, 5%, 10%, 15%, 20%, 30%
- The blue line is the % return of a portfolio that was made up of 100% asset 1 over the time interval. i.e. 100% AMEX:SPY
- Asset weights and rebalancing thresholds are adjustable via the settings
- Each plot can be turned on and turned off via a tick box in the settings
Portfolio Performance - 2 AssetsFunction:
- Can be used to evaluate the performance of portfolios containing 2 assets over a set time interval
- Created to evaluate of the performance of portfolios containing different weightings of stocks and bonds over time
- Shows the % return of each portfolio over the time interval defined by the user
- Capable of showing the risk adjusted % return of each portfolio over the time interval defined by the user (setting turned off by default)
Instructions:
- To be used with dividends adjustments turned on
- Add this script to a symbol. e.g. NASDAQ:BND
- Click the chart to define the entry time and the exit time. i.e. the time interval
- Define the second asset to be included in the portfolio. e.g. AMEX:VOO
- The strategy comes pre-populated with 6 portfolios with the most common stock/bond weightings (100% stocks/0% bonds, 80% stocks/20% bonds, 60% stocks/40% bonds, et cetera)
- The 6 lines show the weighted % return of each portfolio over the time period defined by the user
- All asset weights are adjustable via the settings
- Each plot can be turned on and turned off via a tick box in the settings
- There are 6 plots that show the risk adjusted returns of each portfolio (setting turned off by default)
Portfolio Backtester Engine█ OVERVIEW
Portfolio Backtester Engine (PBTE). This tool will allow you to backtest strategies across multiple securities at once. Allowing you to easier understand if your strategy is robust. If you are familiar with the PineCoders backtesting engine , then you will find this indicator pleasant to work with as it is an adaptation based on that work. Much of the functionality has been kept the same, or enhanced, with some minor adjustments I made on the account of creating a more subjectively intuitive tool.
█ HISTORY
The original purpose of the backtesting engine (`BTE`) was to bridge the gap between strategies and studies . Previously, strategies did not contain the ability to send alerts, but were necessary for backtesting. Studies on the other hand were necessary for sending alerts, but could not provide backtesting results . Often, traders would have to manage two separate Pine scripts to take advantage of each feature, this was less than ideal.
The `BTE` published by PineCoders offered a solution to this issue by generating backtesting results under the context of a study(). This allowed traders to backtest their strategy and simultaneously generate alerts for automated trading, thus eliminating the need for a separate strategy() script (though, even converting the engine to a strategy was made simple by the PineCoders!).
Fast forward a couple years and PineScript evolved beyond these issues and alerts were introduced into strategies. The BTE was not quite as necessary anymore, but is still extremely useful as it contains extra features and data not found under the strategy() context. Below is an excerpt of features contained by the BTE:
"""
More than `40` built-in strategies,
Customizable components,
Coupling with your own external indicator,
Simple conversion from Study to Strategy modes,
Post-Exit analysis to search for alternate trade outcomes,
Use of the Data Window to show detailed bar by bar trade information and global statistics, including some not provided by TV backtesting,
Plotting of reminders and generation of alerts on in-trade events.
"""
Before I go any further, I want to be clear that the BTE is STILL a good tool and it is STILL very useful. The Portfolio Backtesting Engine I am introducing is only a tangental advancement and not to be confused as a replacement, this tool would not have been possible without the `BTE`.
█ THE PROBLEM
Most strategies built in Pine are limited by one thing. Data. Backtesting should be a rigorous process and researchers should examine the performance of their strategy across all market regimes; that includes, bullish and bearish markets, ranging markets, low volatility and high volatility. Depending on your TV subscription The Pine Engine is limited to 5k-20k historical bars available for backtesting, which can often leave the strategy results wanting. As a general rule of thumb, strategies should be tested across a quantity of historical bars which will allow for at least 100 trades. In many cases, the lack of historical bars available for backtesting and frequency of the strategy signals produces less than 100 trades, rendering your strategy results inconclusive.
█ THE SOLUTION
In order to be confident that we have a robust strategy we must test it across all market regimes and we must have over 100 trades. To do this effectively, researchers can use the Portfolio Backtesting Engine (PBTE).
By testing a strategy across a carefully selected portfolio of securities, researchers can now gather 5k-20k historical bars per security! Currently, the PTBE allows up to 5 securities, which amounts to 25k-100k historical bars.
█ HOW TO USE
1 — Add the indicator to your chart.
• Confirm inputs. These will be the most important initial values which you can change later by clicking the gear icon ⚙ and opening up the settings of the indicator.
2 — Select a portfolio.
• You will want to spend some time carefully selecting a portfolio of securities.
• Each security should be uncorrelated.
• The entire portfolio should contain a mix of different market regimes.
You should understand that strategies generally take advantage of one particular type of market regime. (trending, ranging, low/high volatility)
For example, the default RSI strategy is typically advantageous during ranging markets, whereas a typical moving average crossover strategy is advantageous in trending markets.
If you were to use the standard RSI strategy during a trending market, you might be selling when you should be buying.
Similarily, if you use an SMA crossover during a ranging market, you will find that the MA's may produce many false signals.
Even if you build a strategy that is designed to be used only in a trending market, it is still best to select a portfolio of all market regimes
as you will be able to test how your strategy will perform when the market does something unexpected.
3 — Test a built-in strategy or add your own.
• Navigate to gear icon ⚙ (settings) of strategy.
• Choose your options.
• Select a Main Entry Strat and Alternate Entry Strat .
• If you want to add your own strategy, you will need to modify the source code and follow the built-in example.
• You will only need to generate (buy 1 / sell -1/ neutral 0) signals.
• Select a Filter , by default these are all off.
• Select an Entry Stop - This will be your stop loss placed at the trade entry.
• Select Pyamiding - This will allow you to stack positions. By default this is off.
• Select Hard Exits - You can also think of these as Take Profits.
• Let the strategy run and take note of the display tables results.
• Portfolio - Shows each security.
• The strategy runs on each asset in your portfolio.
• The initial capital is equally distributed across each security.
So if you have 5 securities and a starting capital of 100,000$ then each security will run the strategy starting with 20,000$
The total row will aggregate the results on a bar by bar basis showing the total results of your initial capital.
• Net Profit (NP) - Shows profitability.
• Number of Trades (#T) - Shows # of trades taken during backtesting period.
• Typically will want to see this number greater than 100 on the "Total" row.
• Average Trade Length (ATL) - Shows average # of days in a trade.
• Maximum Drawdown (MD ) - Max peak-to-valley equity drawdown during backtesting period.
• This number defines the minimum amount of capital required to trade the system.
• Typically, this shouldn’t be lower than 34% and we will want to allow for at least 50% beyond this number.
• Maximum Loss (ML) - Shows largest loss experienced on a per-trade basis.
• Normally, don’t want to exceed more than 1-2 % of equity.
• Maximum Drawdown Duration (MDD) - The longest duration of a drawdown in equity prior to a new equity peak.
• This number is important to help us psychologically understand how long we can expect to wait for a new peak in account equity.
• Maximum Consecutive Losses (MCL) - The max consecutive losses endured throughout the backtesting period.
• Another important metric for trader psychology, this will help you understand how many losses you should be prepared to handle.
• Profit to Maximum Drawdown (P:MD) - A ratio for the average profit to the maximum drawdown.
• The higher the ratio is, the better. Large profits and small losses contribute to a good PMD.
• This metric allows us to examine the profit with respect to risk.
• Profit Loss Ratio (P:L) - Average profit over the average loss.
• Typically this number should be higher in trend following systems.
• Mean reversion systems show lower values, but compensate with a better win %.
• Percent Winners (% W) - The percentage of winning trades.
• Trend systems will usually have lower win percentages, since statistically the market is only trending roughly 30% of the time.
• Mean reversion systems typically should have a high % W.
• Time Percentage (Time %) - The amount of time that the system has an open position.
• The more time you are in the market, the more you are exposed to market risk, not to mention you could be using that money for something else right?
• Return on Investment (ROI) - Your Net Profit over your initial investment, represented as a percentage.
• You want this number to be positive and high.
• Open Profit (OP) - If the strategy has any open positions, the floating value will be represented here.
• Trading Days (TD) - An important metric showing how many days the strategy was active.
• This is good to know and will be valuable in understanding how long you will need to run this strategy in order to achieve results.
█ FEATURES
These are additional features that extend the original `BTE` features.
- Portfolio backtesting.
- Color coded performance results.
- Circuit Breakers that will stop trading.
- Position reversals on exit. (Simulating the function of always in the market. Similar to strategy.entry functionality)
- Whipsaw Filter
- Moving Average Filter
- Minimum Change Filter
- % Gain Equity Exit
- Popular strategies, (MACD, MA cross, supertrend)
Below are features that were excluded from the original `BTE`
- 2 stage in-trade stops with kick-in rules (This was a subjective decision to remove. I found it to be complex and thwarted my use of the `BTE` for some time.)
- Simple conversion from Study to Strategy modes. (Not possible with multiple securities)
- Coupling with your own external indicator (Not really practical to use with multiple securities, but could be used if signals were generated based on some indicator which was not based on the current chart)
- Use of the Data Window to show detailed bar by bar trade information and global statistics.
- Post Exit Analysis.
- Plotting of reminders and generation of alerts on in-trade events.
- Alerts (These may be added in the future by request when I find the time.)
█ THANKS
The whole PineCoders team for all their shared knowledge and original publication of the BTE and Richard Weismann for his ideas on building robust strategies.
═════════════════════════════════════════════════════════════════════════
Multi-Asset PortfolioWith thanks to luminaryfi for this indicator calculates basic metrics and statistics for a multi-asset portfolio. Note that returns are plotted after being multiplied by 100 in order allow the series to be visible against the other statistics.