I recently saw an article that said if you invested $10,000 in the Netflix IPO in May 2002 it would be worth over $1.5 million today. On the face of it sounds an excellent investment, but when looking at the chart would you really have held on when the price dropped almost 75% in the first 5 months of trading, and 80% in 2004-05 and again in 2011-12? If you would have hung on during those declines – known as drawdowns – then it’s safe to say that you might need to read up on money management!
Here’s the chart of Netflix (set to semi-log scale so that the price scale is in percentage terms so that the price movements are proportional), with the drawdowns marked with the Price Measure tool:
I was thinking that there would be an easier way to visualise these drawdowns on the chart without having to manually apply the PM tool, so I – ok with a bit of help! – came up with a scripting tool that measures the drops from the 52 week high to the lows, and plots it below the chart using the Show View tool:
This script formula calculates the drawdown from a rolling 1 year high:
//Get highest high value over 1 year
H1 = HIGHESTHIGH(RANGE=Look Back Period, BACKTYPE=Years, BARS=1);
//Get the Low price
C1 = LOW();
//Calculates current low from 1 year high in %
CH1 = ((C1-H1) / H1)*100;
P1 = IF(CH1 < 0, CH1, 0);
Plot1 = P1;
Plot1.Plotstyle = Shaded;
This makes it much easier to see the massive drops, and how far the stock has dropped from the current 1 year high.
Note: to change the lookback period for the high value from 1 year to 6 months for example, click on the HIGHESTHIGH text in the script editor window and change the parameters, but note that All Time High will not work in this formula.
What if we also wanted to see what the biggest drawdown was over the history of Netflix? We can do that by adding another plot to our drawdown script (remember that Optuma lets you add tools to tools). Here’s the maximum 1 year drawdown value (80.4%), shown with the red horizontal line:
//to get max drawdown
Plot2 = LAST(LOWESTLOW(p1, RANGE=All Time));
Plot2.Color = Red;
We can also add the average drawdown over the last year (approximately 260 trading days), with the current value shown by the blue line:
Add these lines to the formula:
//Calculate 1 year MA
Plot3 = LAST(MA(P1, BARS=260, CALC=Close));
Plot3.Color = Blue;
So in the example of Netflix, the current drawdown is 14.3%, just below the yearly average of 16.4%, with a maximum 1 year drawdown of 80.4%.
Saving the script as a tool
Don’t forget you can add the script to your toolbox (and then create a custom toolbar button, or add it to a layout) by saving the script as an indicator in a new view (ie it will be applied in its own panel beneath the price chart).
Creating Watchlist Columns
Now that we have the formulas you can also use them in watchlist columns to monitor your portfolio, and sort on the columns. To download an example workbook using World Indices data click the button.
Optuma Scripting Forum
Don’t forget that we have a scripting section on our forum where we provide examples of interesting scripts that we come across, and where clients can share their ideas as well. Lately, Mathew Verdouw, Optuma’s founder, has been sharing scripts that he has been writing for the CMT courses.
To be notified of new forum posts, sign in to the forum using your same Optuma credentials and subscribe to the scripting thread:
Darren Hawkins, MSTA
Senior Software Specialist at Optuma
Darren is the senior Software Specialist at Optuma. He joined the company in 2009 after attending an introductory technical analysis course. Darren now instructs users all over the world, from experienced Wall Street traders and professional money managers to individual traders drawing their first trendlines.
Darren grew up in the UK and attended college in the USA where he earned a BA in Economics from St Mary's College of Maryland. He went on to spend a few years working at the Nasdaq Stock Market in Washington DC. Going on to live and work in Australia, the US and currently the UK, Darren has a broad understanding of the individual needs of traders, portfolio managers and investors utilising a wide range of methodologies.
In 2014 Darren passed the UK-based Society of Technical Analysts diploma course, and when not looking at charts he keeps a keen eye on England's cricket team - especially if they are playing against Australia. He lives in the Essex countryside in England, with wife Wendy and their labrador, Gabba.