custom fitness value on portfolio of multiple instruments?

Questions about MultiCharts and user contributed studies.
User avatar
rokanten
Posts: 48
Joined: 29 Jul 2010
Location: south korea
Has thanked: 15 times

custom fitness value on portfolio of multiple instruments?

Postby rokanten » 17 Oct 2019

hi.

is it possible to use custom fitness value on portfolio trader of 10 instruments?
for example.. if i use averagetrade/mdd as my custom fitness value,
and try to get that value based on all 10 instruments trades, not based on each single instrument,
is it possible?

User avatar
Svetlana MultiCharts
Posts: 645
Joined: 19 Oct 2017
Has thanked: 3 times
Been thanked: 163 times

Re: custom fitness value on portfolio of multiple instruments?

Postby Svetlana MultiCharts » 18 Oct 2019

Hello, rokanten,

Yes, it is possible.
If you set the custom criterion for optimization in your script – then the calculation is performed according to your script logic.
If you calculate the custom criteria in Java-script in Portfolio optimization settings -> Fitness Function window (see screenshot) – the value is based on all instruments of your portfolio. The set of values supported in Portfolio optimization is provided in that window.
Portfolio Custom Criteria.png
(32.89 KiB) Downloaded 168 times

User avatar
rokanten
Posts: 48
Joined: 29 Jul 2010
Location: south korea
Has thanked: 15 times

Re: custom fitness value on portfolio of multiple instruments?

Postby rokanten » 20 Oct 2019

can i use my own proprietary code like monthly return of my strategy on Fitness Function window?
or can i use only reserved words?

User avatar
Svetlana MultiCharts
Posts: 645
Joined: 19 Oct 2017
Has thanked: 3 times
Been thanked: 163 times

Re: custom fitness value on portfolio of multiple instruments?

Postby Svetlana MultiCharts » 21 Oct 2019

In order to set the custom criterion for optimization in your script please use SetCustomFitnessValue keyword:
https://www.multicharts.com/trading-sof ... tnessValue
To apply it in the Optimization window please select Standard Criteria radio button and select Custom Fitness Value from the dropdown list.

User avatar
rokanten
Posts: 48
Joined: 29 Jul 2010
Location: south korea
Has thanked: 15 times

Re: custom fitness value on portfolio of multiple instruments?

Postby rokanten » 21 Oct 2019

i think it's not possible for multi instruments.
for example, custom fitness value as standard deviation of monthly return,
ES 200 300 400
6E -100 200 -300

then what i need is stdev(200,300,400,-100,200,-300)
and it seems what i get is stdev(200,300,400) and stdev(-100,200,300) seperately.

User avatar
Svetlana MultiCharts
Posts: 645
Joined: 19 Oct 2017
Has thanked: 3 times
Been thanked: 163 times

Re: custom fitness value on portfolio of multiple instruments?

Postby Svetlana MultiCharts » 22 Oct 2019

It is required to use the values which are accessible from PowerLanguage.
It is not quite clear from your description what you would like to achieve. Would you mind to provide more details?

User avatar
rokanten
Posts: 48
Joined: 29 Jul 2010
Location: south korea
Has thanked: 15 times

Re: custom fitness value on portfolio of multiple instruments?

Postby rokanten » 22 Oct 2019

ok here it is, simplified,

array:list[10000](0);
var: stdarray(0)...... many var....;

totps=totaltrades;
mp=marketposition;
date0=month(date);
date1=month(date[1]);
symstr=getsymbolname;

(setting starting point for each symbol in array)
if symstr="A6" then smonths=335*0;
if symstr="AP" then smonths=335*1;
if symstr="B6" then smonths=335*2;

{calculate trade profit/loss)
if totps>totps[1] then begin
prof=positionprofit(1)
cumprof=cumprof+prof;
end;

(calculate monthly profit)
if date0<>date1 then begin
if mp<>0 then begin
monthprofit=cumprof
+{open profit}openpositionprofit
end
else begin
monthprofit=cumprof;
end;
deltamonthprofit=monthprofit-monthprofit[1];
if months=0 then months=smonths+1 else months=months+1;
list[months]=round(deltamonthprofit,2);
end;

(setting custom fitness value)
if lastbaronchart then begin
stdarray=StandardDevArray(list,10000,0);
SetCustomFitnessValue(stdarray);
end;

---------------------------------------------------------------------------------------
what i get is std of each symbol's result, not whole symbol.
i understand that, because array can't get results data from other symbols,
i mean.. if portfolio trader moves from one symbol to another symbol,
then that array is being reset, not carrying previous results.

i thought i can be done if i use custum fitness value, but not.
i actually do some excel work for this,
but it's convenient if i can get what i want throught your script, right?

User avatar
Svetlana MultiCharts
Posts: 645
Joined: 19 Oct 2017
Has thanked: 3 times
Been thanked: 163 times

Re: custom fitness value on portfolio of multiple instruments?

Postby Svetlana MultiCharts » 23 Oct 2019

In Portfolio Trader it is possible to apply Money Management (MM) signal where you can get data from other signals and calculate the deviation in it. You can find MM signal examples in this article:
https://www.multicharts.com/trading-sof ... y_Examples


Return to “MultiCharts”