Optimize on Sharpe Ratio

Questions about MultiCharts and user contributed studies.
EdL
Posts: 39
Joined: 18 Feb 2013
Has thanked: 22 times
Been thanked: 11 times

Optimize on Sharpe Ratio

Postby EdL » 28 Feb 2013

Hi,

When optimizing a strategy or portfolio, ideally I would like to optimize based on the Sharpe ratio. Also, I would like to be able to view the Sharpe ratio on the optimisation reports (standard strategy optimization and portfolio optimization).

There is a feature in the Project Management app that says that the Sharpe Ratio has been added to the optimization report and the version with it in released:

https://www.multicharts.com/pm/viewissu ... _no=MC-636

However when I view the Optimization reports it is still not present (please see screenshot attached).

Am I looking in the right place or am I misunderstanding something?

Also, I have added a feature request to allow for optimizing by Sharpe ratio. Please up-vote it!

https://www.multicharts.com/pm/viewissu ... no=MC-1256
Attachments
Screen Shot 2013-02-28 at 18.08.21.png
(143.12 KiB) Downloaded 2818 times

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Optimize on Sharpe Ratio

Postby JoshM » 01 Mar 2013

When optimizing a strategy or portfolio, ideally I would like to optimize based on the Sharpe ratio. Also, I would like to be able to view the Sharpe ratio on the optimisation reports (standard strategy optimization and portfolio optimization).
Isn't this already possible with the SetCustomFitnessValue? I haven't coded it myself, but the parameters for the Sharpe ratio can be calculated in PowerLanguage, and the resulting Sharpe ratio passed to the SetCustomFitnessValue() function.

Dru has made an optimization by linear equity curve here, which may serve as a helpful example.

Dru
Posts: 107
Joined: 28 Aug 2007
Has thanked: 4 times
Been thanked: 171 times

Re: Optimize on Sharpe Ratio

Postby Dru » 01 Mar 2013

No coding needed. There is !optimize by sharp ratio! already in MC.

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

Re: Optimize on Sharpe Ratio

Postby Henry MultiСharts » 01 Mar 2013

When optimizing a strategy or portfolio, ideally I would like to optimize based on the Sharpe ratio. Also, I would like to be able to view the Sharpe ratio on the optimisation reports (standard strategy optimization and portfolio optimization).
Isn't this already possible with the SetCustomFitnessValue? I haven't coded it mysel
It has been already coded by our team. There is a prebuilt signal !optimize by sharp ratio! or optimize_by_sharp_ratio (in MC .Net) that utilizes SetCustomFitnessValue and allows you to optimize your strategy based on Sharpe Ratio.

Add this signal alongside with your trading strategy. We recommend to have it the last in the list as signal calculation priority can be important. Specify Period input (0=monthly, 1=daily):
Image

For exhaustive optimization go to Optimization Criteria tab->Enable "Use limitation"->Standard criteria->Custom Fitness Value.
Image

For genetic optimization go to Algorithm-Specific propeties tab->Standard criteria->Custom Fitness Value.
Image

Click Ok to start the optimization.
Image
Attachments
optimize_sharpe_1.png
(9.87 KiB) Downloaded 3466 times
optimize_sharpe_2.png
(17.7 KiB) Downloaded 3425 times
optimize_sharpe_4.png
(9.2 KiB) Downloaded 3444 times
optimize_sharpe_3.png
(7.84 KiB) Downloaded 3459 times

EdL
Posts: 39
Joined: 18 Feb 2013
Has thanked: 22 times
Been thanked: 11 times

Re: Optimize on Sharpe Ratio

Postby EdL » 12 Mar 2013

Thanks for the responses guys.

Thanks for clarifying how to do this Henry.
I have to say that it would not have been at all obvious how to do this had you not shown me however!
My preference would still be to just be able to select Sharpe Ratio from the list of things to optimize by and I think that would be more obvious to the user. Still, its good I can get the optimization results I'm after without writing my own custom fitness value.

Ed

EdL
Posts: 39
Joined: 18 Feb 2013
Has thanked: 22 times
Been thanked: 11 times

Re: Optimize on Sharpe Ratio

Postby EdL » 12 Mar 2013

p.s. At the risk of sounding extremely pedantic, Sharpe is spelled with an "e" at the end. The ratio is named after Mr. Sharpe, so should be capitalised too. You may want to mention it to the devs as it seems slightly unprofessional having the signal mis-named like that in what is otherwise a very professional piece of software :-)

EdL
Posts: 39
Joined: 18 Feb 2013
Has thanked: 22 times
Been thanked: 11 times

Re: Optimize on Sharpe Ratio

Postby EdL » 27 Mar 2013

I have tried using the optimize_by_sharp_ratio in MC.NET exactly as described but it does not appear to work. I just get a Custom Fitness Values of 0 when using both Daily and Monthly as the inputs to the signal.

I am working with minute bars over a 3 month range.

As you can see form the screenshots; I've added the signal, run the optimization, with results showing Sharpe of 0 and then looking at the Strategy Performance Report there is a Sharpe of (0.23).

Can someone please confirm that this works as expected in MC.NET 8.5 ?

Thanks,

Ed
Attachments
Screen Shot 2013-03-26 at 15.22.54.png
(10.1 KiB) Downloaded 2756 times
Screen Shot 2013-03-26 at 15.19.09.png
(51.76 KiB) Downloaded 2733 times
Screen Shot 2013-03-26 at 15.20.28.png
(29.33 KiB) Downloaded 2713 times

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

Re: Optimize on Sharpe Ratio

Postby Henry MultiСharts » 27 Mar 2013

Hello Ed,

Optimize_by_sharp_ratio works as expected in MC.NET 8.5.
Are you able to replicate this behavior with prebuilt signals like Bollinger Bands or Channel Breakout?

EdL
Posts: 39
Joined: 18 Feb 2013
Has thanked: 22 times
Been thanked: 11 times

Re: Optimize on Sharpe Ratio

Postby EdL » 29 Mar 2013

Hi,

Using exactly the same data, when I apply the prebuilt Bollinger Band signal, the optimize_by_sharp_ratio works, but only for "Monthly" input. When I change input to "Daily", the Sharpe Ratio becomes -1.0.

When I add my signal however, inputs of both Daily and Monthly give a Sharpe Ratio of 0.

(See attached screen shots).

My signal gives rise to about 900 trades and a SR of -1.25 in the Strategy Performance Report
The prebuilt BB signal gives rise to 9000 trades.

Is there something that I need to implement in my signal or a certain trade number I need to reach for the optimize_by_sharp_ratio Custom Fitness Value to work properly?

Thanks,

Ed
Attachments
Screen Shot 2013-03-29 at 14.20.44.png
(32.94 KiB) Downloaded 2725 times
Screen Shot 2013-03-29 at 14.58.34.png
(32.75 KiB) Downloaded 2730 times

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

Re: Optimize on Sharpe Ratio

Postby Henry MultiСharts » 02 Apr 2013

Hello Ed,

We are analyzing this behavior.

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

Re: Optimize on Sharpe Ratio

Postby Henry MultiСharts » 15 Apr 2013

Hi,

Using exactly the same data, when I apply the prebuilt Bollinger Band signal, the optimize_by_sharp_ratio works, but only for "Monthly" input. When I change input to "Daily", the Sharpe Ratio becomes -1.0.

When I add my signal however, inputs of both Daily and Monthly give a Sharpe Ratio of 0.

(See attached screen shots).

My signal gives rise to about 900 trades and a SR of -1.25 in the Strategy Performance Report
The prebuilt BB signal gives rise to 9000 trades.

Is there something that I need to implement in my signal or a certain trade number I need to reach for the optimize_by_sharp_ratio Custom Fitness Value to work properly?

Thanks,

Ed
This issue has been confirmed. It will be fixed in the next version of MultiCharts .Net.

EdL
Posts: 39
Joined: 18 Feb 2013
Has thanked: 22 times
Been thanked: 11 times

Re: Optimize on Sharpe Ratio

Postby EdL » 15 Apr 2013

Thanks for following up on that Henry.

Just to confirm, is there a bug with optimize_by_sharp_ratio not working for both the daily AND monthly settings on user created signals? Or was it just the Daily?

Thanks

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

Re: Optimize on Sharpe Ratio

Postby Henry MultiСharts » 22 Apr 2013

Thanks for following up on that Henry.

Just to confirm, is there a bug with optimize_by_sharp_ratio not working for both the daily AND monthly settings on user created signals? Or was it just the Daily?

Thanks
We have compared monthly sharpe ratio as report shows only мonthly sharpe ratio.

soacm
Posts: 8
Joined: 23 Oct 2022
Has thanked: 2 times

Re: Optimize on Sharpe Ratio

Postby soacm » 31 Jan 2023

Thanks for following up on that Henry.

Just to confirm, is there a bug with optimize_by_sharp_ratio not working for both the daily AND monthly settings on user created signals? Or was it just the Daily?

Thanks
We have compared monthly sharpe ratio as report shows only мonthly sharpe ratio.
Hi, if I want an annualized Sharpe ratio, is it correct if I multiply the result by √12 (if setting the period to monthly)? Or √252 (daily period)?

User avatar
Kate MultiCharts
Posts: 575
Joined: 21 Oct 2020
Has thanked: 7 times
Been thanked: 144 times

Re: Optimize on Sharpe Ratio

Postby Kate MultiCharts » 01 Feb 2023

Thanks for following up on that Henry.

Just to confirm, is there a bug with optimize_by_sharp_ratio not working for both the daily AND monthly settings on user created signals? Or was it just the Daily?

Thanks
We have compared monthly sharpe ratio as report shows only мonthly sharpe ratio.
Hi, if I want an annualized Sharpe ratio, is it correct if I multiply the result by √12 (if setting the period to monthly)? Or √252 (daily period)?
Hi soacm,

In Strategy Performance Report Annualised Sharpe Ratio = Sharpe Ratio monthly based period * SquareRoot(12).

Values calculated in the script with the built-in SharpeRatio function will be approximately the same as in Strategy Performance Report:
Sharpe Ratio daily based period * SquareRoot(365) ~ Annualised Sharpe Ratio
Sharpe Ratio monthly based period * SquareRoot(12) ~ Annualised Sharpe Ratio

ScottishSpeculator
Posts: 47
Joined: 03 Jan 2023
Been thanked: 3 times

Re: Optimize on Sharpe Ratio

Postby ScottishSpeculator » 05 Feb 2023

Kate , are you sure it's square root (365) and not 252 trading days for working out annualised Sharpe ratio. I think as the people above said all outputs should just be automatically converted to annual. Shouldn't have to second-guess this.

Can you just confirm when your running this custom fit value it should be set to the input of 1 and the results from this on a daily chart would be the Sharpe Ratio daily and needs x by 365 for annualised.

User avatar
Kate MultiCharts
Posts: 575
Joined: 21 Oct 2020
Has thanked: 7 times
Been thanked: 144 times

Re: Optimize on Sharpe Ratio

Postby Kate MultiCharts » 06 Feb 2023

Kate , are you sure it's square root (365) and not 252 trading days for working out annualised Sharpe ratio. I think as the people above said all outputs should just be automatically converted to annual. Shouldn't have to second-guess this.

Can you just confirm when your running this custom fit value it should be set to the input of 1 and the results from this on a daily chart would be the Sharpe Ratio daily and needs x by 365 for annualised.
ScottishSpeculator,

SharpeRatio is a pre-built function, the script can be opened in the PowerLanguage Editor for reference. Originally, Sharpe Ratio daily based period is calculated based on 365 days. You can modify the script or create your own to meet your specific needs.

ScottishSpeculator
Posts: 47
Joined: 03 Jan 2023
Been thanked: 3 times

Re: Optimize on Sharpe Ratio

Postby ScottishSpeculator » 06 Feb 2023

I think its normal in the quant/trading world to use 252 is it not? Anyone else got an opinion on this? Thought was a set fixed parameter.

Can you guys create a function for the Sortino Ratio?

nelson712
Posts: 4
Joined: 24 Dec 2015
Has thanked: 2 times
Been thanked: 1 time

Re: Optimize on Sharpe Ratio

Postby nelson712 » 21 Mar 2023

Yes I agree it should be 252.
But I'm not sure if this way still works. I tried it for Daily and Monthly while using Minutebars and no sharpe column appeard in my optimization. :?


Return to “MultiCharts”