Attention! It is working only for MC 8.5 beta 2 or higher. There is a bug with keywords "postrade***" during optimization in less versions.
I found that lots of people are interested in a feature that allowes to optimize a strategy by linear equity curve (https://www.multicharts.com/pm/viewissu ... _no=MC-896).
Here is how to use it: add the signal "!optimize by equity curve std dev!" from attached archive to your signals at the end of the list and run optimization. That is all. This signal maximize netprofit and minimize standard deviation of close to close equity curve.
Example:
Optimization only by NetProfit:
Optimization by NetProfit & Standard Deviation of Close to Close Equity Curve:
Optimization By linear Equity Curve
Optimization By linear Equity Curve
- Attachments
-
- optimize by netprofit & equity std dev.wsp
- (145.46 KiB) Downloaded 1799 times
-
- optimize by net profit & equity std dev.pla
- (4.02 KiB) Downloaded 1597 times
Last edited by Dru on 19 Jan 2013, edited 1 time in total.
- furytrader
- Posts: 354
- Joined: 30 Jul 2010
- Location: Chicago, IL
- Has thanked: 155 times
- Been thanked: 217 times
Re: Optimization By linear Equity Curve
Thanks for writing this - can you explain how we use it though? Do we take the code found in !optimize by equity curve std dev! and put that in our signal? When I do that, I get an STD Exception: invalid argument.
I'm sure I'm doing something wrong here - any help?
I'm sure I'm doing something wrong here - any help?
Re: Optimization By linear Equity Curve
1) Do you use MC 8.5 beta 2?Thanks for writing this - can you explain how we use it though? Do we take the code found in !optimize by equity curve std dev! and put that in our signal? When I do that, I get an STD Exception: invalid argument.
I'm sure I'm doing something wrong here - any help?
2) How to use it: add the signal "!optimize by equity curve std dev!" from attached archive to your signals at the end of the list and run optimization. That is all. It is not necessary copy the code. Look on the attached optimize by netprofit & equity std dev.wsp for example.
If it does not work please attach your wsp for reproduce the issue
Re: Optimization By linear Equity Curve
Dru,Thanks for writing this - can you explain how we use it though? Do we take the code found in !optimize by equity curve std dev! and put that in our signal? When I do that, I get an STD Exception: invalid argument.
I'm sure I'm doing something wrong here - any help?
I am using MC 8.0 and get same error message?
Will appreciate your help.
Thanks for sharing your work.
Regards
Super
-
- Posts: 116
- Joined: 19 Aug 2012
- Location: San Francisco
- Has thanked: 23 times
- Been thanked: 30 times
- Contact:
Re: Optimization By linear Equity Curve
Hi Dru. Thanks for coding this.
I'm using MC 8.5 release. When running an optimization, in the Algorithm-specific Properties tab, what Standard Criteria should be selected? The WS you provided seems to default to "Custom Fitness Value". This should be selected correct?
And if I were to select "Net Profit", would the "Net Profit" criteria over ride the !optimize by equity curve std dev! signal?
Thank again.
I'm using MC 8.5 release. When running an optimization, in the Algorithm-specific Properties tab, what Standard Criteria should be selected? The WS you provided seems to default to "Custom Fitness Value". This should be selected correct?
And if I were to select "Net Profit", would the "Net Profit" criteria over ride the !optimize by equity curve std dev! signal?
Thank again.
Re: Optimization By linear Equity Curve
- "Custom Fitness Value".When running an optimization, in the Algorithm-specific Properties tab, what Standard Criteria should be selected?
- yes.This should be selected correct?
- yes.And if I were to select "Net Profit", would the "Net Profit" criteria over ride the !optimize by equity curve std dev! signal?
!optimize by equity curve std dev! signal just provide "Equity Curve Std Dev" value to the optimizer. But only you will specify what criteria should be used.
Re: Optimization By linear Equity Curve
Thanks for the code.
Are we optimizing by ascending or descending?
Are we optimizing by ascending or descending?
Re: Optimization By linear Equity Curve
Old thread but a big thank you to Dru for this.
I'm looking if any of you guys have another fitness function for comparison for a smoother equity curve. The reason is in certain instances majority of profits happen in a year and remain flat afterwards and the net profit/equity standard deviation is ranked high.
I'm looking along the lines somewhat like the perfect profit correlation in TS or equity curve correlation coefficient with net profit from Adaptrade. I'm having trouble translating the code from Adaptrade into a function in MC custom fitness value field either getting array errors or code running too slow to effeciently optimize. Appreciate if anyone could point me in the right direction. Thanks!
http://help.TS.com/09_00/Trad ... fields.htm
http://www.adaptrade.com/BreakoutFuture ... er1104.htm
I'm looking if any of you guys have another fitness function for comparison for a smoother equity curve. The reason is in certain instances majority of profits happen in a year and remain flat afterwards and the net profit/equity standard deviation is ranked high.
I'm looking along the lines somewhat like the perfect profit correlation in TS or equity curve correlation coefficient with net profit from Adaptrade. I'm having trouble translating the code from Adaptrade into a function in MC custom fitness value field either getting array errors or code running too slow to effeciently optimize. Appreciate if anyone could point me in the right direction. Thanks!
http://help.TS.com/09_00/Trad ... fields.htm
http://www.adaptrade.com/BreakoutFuture ... er1104.htm
Re: Optimization By linear Equity Curve
Can be written as following in custom criterion
// TODO: Enter your formula to replace the samples below
/************************************* Sample 1 ******************************************/
if (StrategyPerformance.MaxStrategyDrawDown != 0) {
return StrategyPerformance.NetProfit / (-StrategyPerformance.MaxStrategyDrawDown);
}
// TODO: Enter your formula to replace the samples below
/************************************* Sample 1 ******************************************/
if (StrategyPerformance.MaxStrategyDrawDown != 0) {
return StrategyPerformance.NetProfit / (-StrategyPerformance.MaxStrategyDrawDown);
}
Attention! It is working only for MC 8.5 beta 2 or higher. There is a bug with keywords "postrade***" during optimization in less versions.
-
- Posts: 196
- Joined: 08 Aug 2012
- Has thanked: 41 times
- Been thanked: 41 times
Re: Optimization By linear Equity Curve
Hi
How can I get the equity curve line indicator at the bottom of the chart ?
Must I only use this workspace to get that ?
thanks
shane
How can I get the equity curve line indicator at the bottom of the chart ?
Must I only use this workspace to get that ?
thanks
shane
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Optimization By linear Equity Curve
Hello shane,Hi
How can I get the equity curve line indicator at the bottom of the chart ?
Must I only use this workspace to get that ?
thanks
shane
You can use i_OpenEquity or GetPositionOpenPL in your code to do that.
Re: Optimization By linear Equity Curve
Hello,
I'm really excited to see this metric!
I was able to get it working using the provided workspace.
I then tried to get my own workspace working but the Custom Fitness Value is always 0 and I'm not sure why.
My custom workspace has a data1 and data2, 5 min bars for 5 years.
The !optimize! signal is the last and status is on, "Custom 1 Line" works and shows the equity.
Thinking it maybe something in EquityCurveStdDev
Or StandardDevArray
Thanks in advance.
I'm really excited to see this metric!
I was able to get it working using the provided workspace.
I then tried to get my own workspace working but the Custom Fitness Value is always 0 and I'm not sure why.
My custom workspace has a data1 and data2, 5 min bars for 5 years.
The !optimize! signal is the last and status is on, "Custom 1 Line" works and shows the equity.
Thinking it maybe something in EquityCurveStdDev
Code: Select all
Input: CalculateRatio(TrueFalseSimple) {final calculation};
if CalculateRatio then begin
array: equty_per_bar[](0);
var: intrabarpersist last_idx(0);
for value1 = maxpositionsago downto 0 begin
value3 = PosTradeCount(value1)-1;
for value2 = 0 to value3 begin
last_idx += 1;
array_setmaxindex(equty_per_bar, last_idx);
equty_per_bar[last_idx] = PosTradeProfit(value1, value2);
//print( "trade [", maxpositionsago - value1, ",", value2, "] = ", equty_per_bar[last_idx]);
end;
end;
EquityCurveStdDev = StandardDevArray( equty_per_bar, last_idx, 0 );
// if 0=getappinfo(aioptimizing) then print( "EquityCurveStdDev = ", EquityCurveStdDev );
end;
Code: Select all
inputs:
PriceValueArray[MaxSize]( numericarray ),
Size( numericsimple ),
DataType( numericsimple ) ;
Value1 = VarianceArray( PriceValueArray, Size, DataType ) ;
if Value1 > 0 then
StandardDevArray = SquareRoot( Value1 )
else
StandardDevArray = 0 ;
Thanks in advance.