Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Ayumi), 838 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Reinvesting Profits #409899
10/24/12 11:03
10/24/12 11:03
Joined: Sep 2012
Posts: 99
T
TankWolf Offline OP
Junior Member
TankWolf  Offline OP
Junior Member
T

Joined: Sep 2012
Posts: 99
Ive been playing around with the reinvesting profits aspect of script writing and I have a few questions for anyone that can answer.

When I check the tutorials and manuals Im finding multiple different code for reinvesting profits, and when testing they all seem to achieve different results.

http://zorro-trader.com/manual/en/tutorial_kelly.htm
Quote:

if(OptimalFLong > 0 and OptimalFShort > 0)
Margin = (100+0.2*Equity)*(OptimalFLong+OptimalFShort);


Equity for starters is not in Zorro's variables but the help says that Balance + TradeVal = Equity. Should that be used there instead? I have tried it and whenever I changed the 0.2 factor to another number for example 0.5 the result didn't change. Another idea I had was to try Profits or even WinTotal - LossTotal instead of Equity but Im sure they dont work correctly as the capital required always rises alot.

From WorkShop 6_2 script in Zorro.
Quote:

if(Train)
Lots = 1;
else if(OptimalFLong > 0) {
Lots = 1;
Margin = clamp(Balance * OptimalFLong * 0.1, 5, 1000);
} else if(OptimalFShort > 0) {
Lots = 1;
Margin = clamp(Balance * OptimalFShort * 0.1, 5, 1000);
} else
Lots = 0; // switch off trading


This is the example from the actual script on Zorro minus the Algos just for being run on a single strategy.

http://forums.babypips.com/expert-adviso...y-design-3.html
Quote:

if(Train)
Lots = 1;
else if(OptimalFLong > 0) {
Lots = 1;
Margin = clamp((WinLong-LossLong) * OptimalFLong/2, 50, 10000);
} else if(OptimalFShort > 0) {
Lots = 1;
Margin = clamp((WinShort-LossShort) * OptimalFShort/2, 50, 10000);
} else
Lots = 0;


And I found this example from Babypips, like all have very different effects on my strategy and in most cases makes the required capital rise. Any help in understanding reinvesting profits more throughly will be appreciated.

Re: Reinvesting Profits [Re: TankWolf] #409900
10/24/12 11:31
10/24/12 11:31
Joined: Oct 2012
Posts: 75
H
hughbriss Offline
Junior Member
hughbriss  Offline
Junior Member
H

Joined: Oct 2012
Posts: 75
I too have had massive problems working out how any of this works. I still haven't fully and have resigned myself to just trading at 1 micro lot per trade and as the balance gets bigger I can slowly increase the lot size manually.

Last edited by hughbriss; 10/24/12 11:31.
Re: Reinvesting Profits [Re: hughbriss] #409904
10/24/12 12:06
10/24/12 12:06
Joined: Sep 2012
Posts: 99
T
TankWolf Offline OP
Junior Member
TankWolf  Offline OP
Junior Member
T

Joined: Sep 2012
Posts: 99
To further illustrate what I mean here are the results for a strategy I have written:

Originally Posted By: "Without reinvesting"

if(OptimalFLong > 0 and OptimalFShort > 0)
Margin = 100*(OptimalFLong+OptimalFShort);

Capital Required 544
Profit 2408
Annual return 195%
Profit factor 1.29 (PRR 1.18)
Sharpe ratio 1.60
Kelly criterion 1.31
OptimalF .062
Ulcer index 6%
Prediction error 16%


Originally Posted By: "Code 1 from 1st post using WinTotal-LossTotal instead of Equity"

Capital required 11311
Profit 6182
Annual return 24%
Profit factor 1.09 (PRR 1.00)
Sharpe ratio 0.47
Kelly criterion 0.89
OptimalF .007
Ulcer index 19%
Prediction error 16%


Originally Posted By: "Code 2 from 1st post"

Capital required 205
Profit 772
Annual return 166%
Profit factor 1.26 (PRR 1.15)
Sharpe ratio 1.55
Kelly criterion 1.44
OptimalF .072
Ulcer index 7%
Prediction error 16%


Originally Posted By: "Code 3 from 1st post"

Capital required 2751
Profit 7606
Annual return 122%
Profit factor 1.21 (PRR 1.11)
Sharpe ratio 1.22
Kelly criterion 1.22
OptimalF .027
Ulcer index 9%
Prediction error 16%


Hpoefully this should show clearer... because the way I read the manual and lessons regarding reinvesting profits was the whole point was to make more money from the same amount of starting capital. And in each of these examples on the same script the starting capital & profits changed dramatically.


Re: Reinvesting Profits [Re: TankWolf] #409908
10/24/12 13:00
10/24/12 13:00
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
I believe Equity is always zero in your Zorro version, that's why it is not documented. We update the online manual while we add features, and Equity was only implemented in the current Zorro that is not yet released. So use only the examples in your Zorro manual, not in the online version.

Balance is the total money in the account and (WinLong-LossLong) is the money earned by the strategy component. When testing a strategy with only 1 component, both are identical, but on a portfolio strategy they are different.

http://zorro-trader.com/manual/en/winloss.htm

Balance and Equity should both not be used in a strategy, as they reflect the situation of your account, not of your strategy. That was a mistake in some tutorials. Instead of Equity, use

var Gain = WinTotal - LossTotal + WinValTotal - LossValTotal;

That is the profit so far by all components of your strategy.


Re: Reinvesting Profits [Re: jcl] #409909
10/24/12 13:29
10/24/12 13:29
Joined: Sep 2012
Posts: 99
T
TankWolf Offline OP
Junior Member
TankWolf  Offline OP
Junior Member
T

Joined: Sep 2012
Posts: 99
Ok thanks I'll take that into account.

But as I posted in my code with trading statistics above there are two other methods of reinvesting in the tutorials you posted (Code 2 & 3 from the original post) that should if I understand the lessons correctly the whole point of implementing reinvestment is to make more profit from the same amount of starting capital?

Edit: Now I look at Code 2 again I notice it does use Balance, though I pulled that code directly from Workshop 6_2. My question above should still apply to Code 3 from my original post though it does not and as you can see changes the required capital from 544 to 2751.

Re: Reinvesting Profits [Re: TankWolf] #409912
10/24/12 15:21
10/24/12 15:21
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
As explained in the manual, the performance parameters are for positive returns and constant margin only. The required capital can not be calculated when the capital is reinvested. You must determine it _before_ reinvesting the profits.

It is theoretically possible to calculate the required capital in a reinvesting strategy by applying weight factors to the equity curve. But that is nontrivial and reserved for a future Zorro version.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1