Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (NewbieZorro, TipmyPip, 1 invisible), 19,045 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Does this OptF seem correct? #430259
09/26/13 10:05
09/26/13 10:05
Joined: Jul 2013
Posts: 522
D
dusktrader Offline OP
User
dusktrader  Offline OP
User
D

Joined: Jul 2013
Posts: 522
In a test strategy I'm working with I get the following OptF results after adding Margin and reinvestment:
Quote:
Annual growth rate 129%
Profit factor 1.67 (PRR 1.34)
Sharpe ratio 0.85
Kelly criterion 0.15
Ulcer index 14%
Prediction error 42%
Cycle performance 1.84 1.83 1.79 1.45 1.64 1.83 1.69 1.82

Portfolio analysis OptF ProF Win/Loss Wgt% Cycles

EURUSD .505 1.82 53/229 134.9 X//X
EURUSD:L .164 1.32 34/155 4.0 \///
EURUSD:S .999 1.86 19/74 130.9 ///\


I noticed in the testtrades.csv log, it is calculating lots for Shorts far bigger than Longs, sometimes 10x more. That may all be correct (if so, that's what I want). But it seems abnormal that OptF is .999 -- can you confirm that is correct?

Here is the code I'm using for reinvestment. Please advise if you have any suggestions here. I see various code for this around the forum and help pages, but this seems to be one of the more recent calculations:
Code:
//reinvest a portion of profits
	int reinvestprofits = 1; //invoke margin setting during trade logic
	Capital = 1000; //simulate starting account with $1000
	var MarginLong = OptimalFLong * Capital * sqrt(1 + (WinLong-LossLong)/Capital);
	var MarginShort = OptimalFShort * Capital * sqrt(1 + (WinShort-LossShort)/Capital);



Thank you

Re: Does this OptF seem correct? [Re: dusktrader] #430264
09/26/13 10:25
09/26/13 10:25
Joined: Jul 2013
Posts: 522
D
dusktrader Offline OP
User
dusktrader  Offline OP
User
D

Joined: Jul 2013
Posts: 522
I guess the reason I'm confused on the OptF calculation is...

If overall strategy is .505 with 1.82 ProF,
how can short have a similar ProF of 1.86 but so much higher OptF?

Re: Does this OptF seem correct? [Re: dusktrader] #430268
09/26/13 10:43
09/26/13 10:43
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
OptF is not equivalent to ProF. If it were so, you could use the ProF instead of OptF, which is much harder to calculate. The .999 looks correct.

OptimalF factors are calculated from the whole balance curve, which the ProF is only the win to loss ratio. Balance drawdowns affect OptimalF, but not ProF.

We also used various formulae for calculating the margin from OptimalF, but what you're using above is the best method.

Re: Does this OptF seem correct? [Re: jcl] #430270
09/26/13 10:51
09/26/13 10:51
Joined: Jul 2013
Posts: 522
D
dusktrader Offline OP
User
dusktrader  Offline OP
User
D

Joined: Jul 2013
Posts: 522
Ok, I understand what you are saying, that OptF and ProF are not comparable metrics.

But can you confirm .999 is not a glitch? It seems unlikely that .999 would ever be assigned. (I think) that says that 99.9% of the margin should be devoted to this component.

Re: Does this OptF seem correct? [Re: dusktrader] #430275
09/26/13 11:31
09/26/13 11:31
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
Yes, it is not a glitch. But it is indeed a special value.

It sometimes happens that the backtest balance curve has very little drawdown. Then the maximum gain can be achieved when assigning the full capital to that component. OptimalF is then at 0.999. I would here not use separate OptimalF for long and short, but one OptimalF for both, even if this reduces backtest profit.

Re: Does this OptF seem correct? [Re: jcl] #430294
09/26/13 13:56
09/26/13 13:56
Joined: Jul 2013
Posts: 522
D
dusktrader Offline OP
User
dusktrader  Offline OP
User
D

Joined: Jul 2013
Posts: 522
Perhaps I could use separate OptimalF factors for long and short, but limit them with the strategy's overall OptimalF value. Like this:

Code:
//reinvest a portion of profits
	int reinvestprofits = 1; //invoke margin setting during trade logic
	Capital = 1000; //simulate starting account with $1000
	var MarginLong = OptimalF * OptimalFLong * Capital * sqrt(1 + (WinLong-LossLong)/Capital);
	var MarginShort = OptimalF * OptimalFShort * Capital * sqrt(1 + (WinShort-LossShort)/Capital);



I'd like to be able to use separate figures because in some cases one of the components is really bad, as seen in this example.

Re: Does this OptF seem correct? [Re: jcl] #433697
12/04/13 16:27
12/04/13 16:27
Joined: Jul 2013
Posts: 522
D
dusktrader Offline OP
User
dusktrader  Offline OP
User
D

Joined: Jul 2013
Posts: 522
Hi jcl, I came across this OptimalF value of 0.999 again. I don't fully understand why this happens. I am concerned that it is not normal, and that it could be caused from something I'm doing incorrectly. See below on USDJPY which shows .999 for longs and .000 for shorts.

I'll post here also the USDJPY chart for this strategy.
Thanks for taking a look at this.

Code:
Portfolio analysis  OptF  ProF  Win/Loss  Wgt%  Cycles

AUDUSD avg          .167  1.35  1148/3094146.4  //X/
EURAUD avg          .726  1.63  537/1673 381.9  ////
EURCAD avg          .328  1.27  1557/2572146.9  /\//
NZDJPY avg          .098  1.39  2588/2829376.2  \///
USDJPY avg          .499  2.72  652/752  448.6  /\//

AUDUSD              .139  1.35  1148/3094146.4  //X/
AUDUSD:L            .116  1.37  823/2071  94.9  ////
AUDUSD:S            .218  1.33  325/1023  51.5  //\/
EURAUD              .612  1.63  537/1673 381.9  ////
EURAUD:L            .459  1.35  334/1119 108.9  ////
EURAUD:S            .994  1.91  203/554  273.0  ////
EURCAD              .339  1.27  1557/2572146.9  /\//
EURCAD:L            .374  1.35  1104/1584122.8  /\//
EURCAD:S            .283  1.13  453/988   24.2  /\//
NZDJPY              .117  1.39  2588/2829376.2  \///
NZDJPY:L            .196  1.39  2588/2829376.2  \///
NZDJPY:S            .000  ----    0/0      0.0  ....
USDJPY              .999  2.72  652/752  448.6  /\//
USDJPY:L            .999  2.72  652/752  448.6  /\//
USDJPY:S            .000  ----    0/0      0.0  ....



EDIT: I should note also that this may be normal/correct. In looking at the testtrades log, I see that Zorro took the maximum Lot size on every USDJPY long trade as indicated above. However, even the worst losing trade was only a 6% loss (and far less than the MAE %).

Attached Files dt-e8_USDJPY.png
Last edited by dusktrader; 12/04/13 16:45.
Re: Does this OptF seem correct? [Re: dusktrader] #433713
12/05/13 07:45
12/05/13 07:45
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
Factors close to 1, as for USDJPY:L and EURAUD:S are unusual, but can happen. Aside of future peeking or overfitting, I cannot think of a method to do something incorrectly for getting too high OptF factors.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1