Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to calculate max drawdown

I have a table:

Date,P&L

May 1,100

May 2,100

May 3,-50

May 4,200

May 5,-100

May 6,-200

the Cumulative P&L is

Date,Cumulative P&L

May 1,100

May 2,200

May 3,150

May 4,350

May 5,250

May 6,50

the drawdown is defined as drop from previous peak cumulative P&L

Date,Drawdown

May 1,0

May 2,0

May 3,50

May 4,0

May 5,100

May 6,300

so Max drawdown is 300

I want to put it in the qlivkiew formula so that when I select a range of dates, the max drawdown value is automatically calculated.

4 Replies
Not applicable
Author

QlikView calculation is dynamic. In your case, put Max(Drawdown) in text box. Add Date list box.

Select the date ranges from list box, you can see that text box value changes based on your date range selection.

Thanks,

Vinod Kumar V

Not applicable
Author

but I need qlikview to calculate the drawdown.

jonathandienst
Partner - Champion III
Partner - Champion III

To do this in the load script:

PnL:

LOAD *,

  RangeMax(0, PeakPnL- CumPnL) As Drawdown

;

LOAD *,

  RangeMax(Peek(PeakPnL), CumPnL) As PeakPnL

;

LOAD *,

  PnL + Alt(Peek(CumPnL), 0) As CumPnL

;

LOAD Date(Date#(Year(Today()) & Date, 'YYYYMMMM D')) As Date,

  PnL

Inline

[

  Date,PnL

  May 1,100

  May 2,100

  May 3,-50

  May 4,200

  May 5,-100

  May 6,-200

];

(change the inline load to your actual data source)

test.png

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

this doesn't work as cumpnl needs dynamically change upon the dates selected.

e.g. if I select only May 5 and May 6, the cumpnl is -100, -300, and drawdown are 0