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?
Portfolio fitness function using symbol metrics possible?
- Polly MultiCharts
- Posts: 202
- Joined: 20 Jul 2022
- Has thanked: 1 time
- Been thanked: 56 times
Re: Portfolio fitness function using symbol metrics possible?
Hello wilkinsw,
You might try using the following method:
You might try using the following method:
- 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;
- Add this signal to the Money Management Signal field.
- Optimize by Custom Fitness value.
- Apply max input.
- Open Output tab in the PowerLanguage Editor.
- Backtest your strategy.