Portfolio fitness function using symbol metrics possible?

Questions about MultiCharts and user contributed studies.
wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Portfolio fitness function using symbol metrics possible?

Postby wilkinsw » 17 Oct 2023

Hi,

Is it possible to optimize a portfolio of symbols in PTO using a fitness function that can access the results for individual symbols?

For example:

Is it possible to find the highest net profit value for a given symbol from a given backtest run, during a genetic algorithm optimization, using a fitness function, and use that value to steer the optimization?

User avatar
Polly MultiCharts
Posts: 203
Joined: 20 Jul 2022
Has thanked: 1 time
Been thanked: 56 times

Re: Portfolio fitness function using symbol metrics possible?

Postby Polly MultiCharts » 09 Nov 2023

Hello wilkinsw,

You might try using the following method:
  1. Create and compile the following signal:

    Code: Select all

    var: ind(0); var: maxNetprofit(0); maxNetprofit = 0; if not LastBarOnChart then #return; For ind = 0 to pmms_strategies_count - 1 Begin if getappinfo(aiOptimizing ) = 0 then begin Print(pmms_strategy_symbol(ind), " ", pmms_strategy_netprofit(ind )); end; if pmms_strategy_netprofit(ind) > maxNetprofit then begin maxNetprofit = pmms_strategy_netprofit(ind ); end; End; SetCustomFitnessValue(maxNetprofit ); if getappinfo(aiOptimizing ) = 0 then begin Print(" END ", maxNetprofit ); end;
  2. Add this signal to the Money Management Signal field.
  3. Optimize by Custom Fitness value.
    Portfolio Trader.png
    (166.52 KiB) Not downloaded yet
  4. Apply max input.
  5. Open Output tab in the PowerLanguage Editor.
  6. Backtest your strategy.
    Output.png
    (114.67 KiB) Not downloaded yet
Please see the screenshot attached for reference.


Return to “MultiCharts”