Max draw down coding.
26 Apr 2013, 08:17
Hi,
please give me the right way to code the max draw down so it is inline with the way you calculate the back testing draw down.
Account.Balance is used I would think and based on historical high and declining low.
Thanks..
Replies
kricka
26 Apr 2013, 17:22
Hi,
tried to compile /forum/calgo-reference-samples/823 and came up with an error. Please correct so I can test and use the sample.
Thanks..
@kricka
cAlgo_Fanatic
26 Apr 2013, 18:01
Can you please recopy the code and let us know if you get the error? Also, let us know what error you are getting.
@cAlgo_Fanatic
cAlgo_Development
30 Apr 2013, 12:50
OK, code is corrected. Refresh the page and try again please.
@cAlgo_Development

cAlgo_Fanatic
26 Apr 2013, 11:31
Please see this sample for Max DrawDown.
In the example this is the function that calculates it which is called when the position closes, in the OnPositionClosed event:
private void GetMaxDrawDown() { peak = Math.Max(peak, Account.Balance); Array.Resize(ref drawdown, drawdown.Length + 1); int i = drawdown.Length - 1; drawdown[i] = (peak - Account.Balance) / peak * 100; for (i = 0; i < drawdown.Length; i++) maxDrawdown = Math.Max(maxDrawdown, drawdown[i]); Print("Max DrawDown = {0}", Math.Round(maxDrawdown, 2)); }@cAlgo_Fanatic