![]() By returning the price level, I could use this information to buy dips, place or trail a stop, and buy or sell a put option at that level.įor instance, lets say I want to dip buy on SPY. I revised the code to include a Label displaying the price level of the associated mark level specified by the user. Likewise if prices were small then suddenly large, the price fluctuations and drawdowns looks smaller than they really were (e.g. A chart showing a price starting at 50, peaking at 100, then dropping to 75 will visually appear to be in a 50% drawdown since it takes up half the screen, but it is really just a 25% drawdown. I really like having the drawdown plot since the charts scale (i.e. Looking forward to seeing how far this goes! I could probably figure this out, and will try this weekend if no one steps forward, but it'd be great if anyone had the interest and talent to help code it. If anyone is keen on giving a try at coding this, I'm happy to work with you on it. Essentially, new highs dictate the new level, and anytime price goes under the recent high, a cloud level remains above it, almost like the stock is going underwater. Two, is on the chart itself, as a cloud above any lower price action. Anytime price drops below the all time high, it becomes subtracted and shown in percent from high, in the indicator. ![]() A zero line represents days where it's making new highs. One, is how you would see it on portfolio manager's risk charts. Now, in my mind, there are two ways to display this. No matter what timeframe you are on, being able to visualize it, can really help you assess if you want to get into the position or not. So, being able to see drawdown in relationship with a stock which is ripping and roaring can help you know if it's a good or poor opportunity. When you divide the return over time by the risk over the same time, you get the Sortino ratio, which is a measure of how much reward you are getting for your risk. It's an excellent indication of risk and volatility. I searched around the web and forum for a ThinkScript indicator to show drawdown %, and could not find that anyone has created a drawdown % indicator. One of the ways you can visually see how resilient a stock is over time, is by checking it's drawdowns in %. Aside from pandemics and giant market pullbacks, those stocks have great resiliency, and when they consolidate, they go sideways, not down. Some excellent examples are the daily charts on MSFT and LULU to name a few. And one of the factors that makes a chart "gorgeous" to me, is that is has a strong trend coupled with low volatility and high performance. Highwatermark.I have an obsession with stocks that have gorgeous charts. May like to start further bug-tracing with a cross-check-ing of the state of objects and the call-signature: try:įor t in np.arange( 1, cumret.shape ): Where a tuple was attempted to get constructed on the right hand side of the value-assignment (well, actually an object-reference gets assigned in python, sure, but was trying to remain short here to tell that fast for an easy reading ), the first item of which was expected to get assigned to a returned value from a call to the above documented np.maximum(.) function. This simply fails to meet the expected behaviour once only one of the expected pair of values was delivered in the reported line ( see the closing parenthesis ), or a scalar or any other, non-array-like type of object(s) were attempted to be delivered into the call-signature: highwatermark = ( np.maximum( highwatermark ), cumret ) ![]() Your code uses a call to a numpy function having a defined a minimum-call-signature as: Q: What code do I need to change for my code to work? MaxDrawdown = calculateMaxDD(cumret.values)įile "Ex3_4.py", line 15, in calculateMaxDD MaxDD, i = np.min(drawdown, np.argmin(drawdown)) # drawdown Highwatermark = (np.maximum(highwatermark), cumret)ĭrawdown = ((1+ cumret )/(1 + highwatermark) - 1)ĭrawdownduration = drawdownduration + 1 # CALCUALTING MAXDD AND CREATING THE FUNCTION.ĭrawdownduration = np.zeros(cumret.shape) What code do I need to change for my code to work? import numpy as npįrom MaxDD_Function import calculateMaxDD ![]() I followed the code to the T and has worked perfectly up until now, and I seem to be getting a ValueError Exception. Im trying to follow an exercise on calculating the maximum drawdown and maximum drawdown duration of a market market neutral vs a long-only trading strategy. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |