Hello,

In the backtest attached, I have used the starting cash and Portfolio.TotalPortfolioValue property to calculate the Portfolio Drawdown overtime and plot it (lines 54-70).

I have also used an ExponentialMovingAverage (line 25) which I update manually in the OnData block with the calculated Drawdown value (line 64).

However, the value of the EMA(30) seems way to close to the calculated Drawdown value when looking at the plot. The plot makes more sense when I significantly increase the period of the EMA (e.g. 250). I suspect this is an issue with the resolution of the EMA which is not in synch with the rest of the algo (consolidated 24 hourly bars for that example), but I cannot figure out how to fix it. Can somebody help?

Author