Thanks for the reply This isn't quite what I am after. That gives the violet coloured line below for the Rolling Max: Plot(RollingMax, "Rolling Max", colorViolet, styleThick) Plot( MaxDD, "Max DD", colorRed, styleNoLabel ) Plot( DD, "Drawdown ", colorBlue, styleGradient | styleLine ) SetGradientFill( GetChartBkColor(), colorBlue, 0 ) drawdown %.2g%%", DD, LastValue( MaxDD ) ) Title = StrFormat("Drawdown = %.2g%%, Max. So using the default Underwater Equity chart code as a starting point, you could have: EQ = C I'm not sure I fully understand exactly what you're trying to achieve, but as an example, if you were just looking for the rolling max drawdown in the last 252 bars, you could simply use the LLV() function. It's almost always simpler to code and much quicker to execute. I know this is very noob but if anyone can help me out I would be very appreciative.īefore resorting to loops, you should always consider whether what you're after can be achieved with array processing. I’ve spent considerable time on this and really am stuck. If( Name() != "~~~EQUITY" AND Name() != "~~~OSEQUITY" ) Title = "Warning: wrong ticker! This chart should be used on ~~~EQUITY or ~~~OSEQUITY only" SetChartOptions( 2, 0, chartGridPercent ) Plot( ddMaxSys, "", colorLightYellow, styleLine ) Title = StrFormat( "Annual Rolling Drawdowns" ) I want the nested for loop to stop after 252 bars (or if BarCount 0 ) // Subsequent barsĮqMax = Max( eq, eqMax ) // Equity high water levelĭd = 100 * ( eq / eqMax - 1 ) // Daily draw downĭdMax = Min( dd, ddMax ) // Maximum draw downĭdMaxSys = ddMax // Capture maximum draw downs from nested loop.The nested for loop calculates the maximum draw downs every bar by doing the following calculations:Ī) Equity high water level looking forward 252 bars only.The primary for loop captures the maximum draw downs calculated after each iteration of the nested loop.My methodology was to use a nested loop as follows: I want to store the maximum draw downs for each bar in an array and plot it. How I want it to work is to take the back test equity curve, move along it bar by bar, look 252 days ahead and calculate the maximum draw down. I am trying to create a rolling annual maximum draw down plot in the back test report.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |