Max Drawdown code

Questions about MultiCharts and user contributed studies.
ctu1121
Posts: 135
Joined: 05 Jul 2012
Has thanked: 10 times
Been thanked: 4 times

Max Drawdown code

Postby ctu1121 » 24 Jul 2014

Hi there,
I know there is Max Drawdown(MDD) review function on MultiCharts, I could write "Signal" code and review MDD number.

May I calculate MDD for "Indicator"? Example indicator code as below:

Code: Select all

value1=close of data1*5; // calculate YM market value
value2=close of data2*20;// calculate NQ market value
value3=value1-value2;
plot1(value3);
I could use above code to draw a indicator line. May I calculate MDD for this indicator line?
Thanks.

Charles

User avatar
furytrader
Posts: 353
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 217 times

Re: Max Drawdown code

Postby furytrader » 24 Jul 2014

No, the Maximum Drawdown number is calculated only for trading systems, not for indicators.

However, it wouldn't be hard to track the maximum generated value - for example:

Code: Select all

Vars: MaxDD(0);

value1=close of data1*5; // calculate YM market value
value2=close of data2*20;// calculate NQ market value
value3=value1-value2;
plot1(value3);

if value3 < maxDD then maxDD = value3;
If LastBarOnChart = TRUE Then Print("Maximum Drawdown = ",NumToStr(maxDD,4));
[Note that this code is assuming that value3 becomes negative; if this is not true, initialize MaxDD with a sufficiently high number like MaxDD(100000)]

As long as you have your PowerLanguage Editor open, you should see the resulting value printed in the "output" tab at the bottom of your editor screen.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2944 times

Re: Max Drawdown code

Postby Henry MultiСharts » 24 Jul 2014

MaxIDDrawDown can only be used in signals. Since MultiCharts 9.0 that is possible to send a value from a signal to an indicator withing one chart in order to have it plotted by indicator.

Write the following in the signal:

Code: Select all

i_setplotvalue(111, maxiddrawdown)
Indicator:

Code: Select all

plot1(i_getplotvalue(111), "MaxIDDrawdown");


Return to “MultiCharts”