Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (TipmyPip, AndrewAMD, Quad, aliswee, degenerate_762), 970 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Capital does not change with trades being closed? #468269
09/27/17 16:01
09/27/17 16:01
Joined: Sep 2017
Posts: 235
H
Hredot Offline OP
Member
Hredot  Offline OP
Member
H

Joined: Sep 2017
Posts: 235
I put

Code:
if(is(INITRUN)) {
    Capital = 5000;    // starting capital
}



at the top of my run() routine.
The strategy then performs trades and closes trades with profits and losses. But for some reason the Capital and CapitalClosed variables do not get updated properly:



While CapitalClosed registers some loss at the beginning it then just stops registering the other trade results. And Capital just never gets updated.

Am I doing something wrong? Should I include more commands to make these quantities properly track the current state of affairs?

Thanks for any suggestion!

Last edited by Hredot; 09/27/17 16:06.
Re: Capital does not change with trades being closed? [Re: Hredot] #468271
09/27/17 17:54
09/27/17 17:54
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
You are reading input values and expecting an output. laugh You don't even need to say if(is(INITRUN)) - it makes no difference.

Here's how to get it done:
Code:
plot("Sim Balance",(Capital + WinTotal - LossTotal),NEW,RED);

Bon appétit.

Last edited by AndrewAMD; 09/27/17 18:44.
Re: Capital does not change with trades being closed? [Re: AndrewAMD] #468273
09/27/17 20:28
09/27/17 20:28
Joined: Sep 2017
Posts: 235
H
Hredot Offline OP
Member
Hredot  Offline OP
Member
H

Joined: Sep 2017
Posts: 235
Oh... Thanks for the answer, but now I am a bit confused.
In the portfolio management section of the tutorial the variables Capital and ProfitClosed are used to determine how much to reinvest at any given time. If these variables are actually supposed to be input only and therefore always constant, how to reconcile this with the tutorial?

Re: Capital does not change with trades being closed? [Re: Hredot] #468274
09/27/17 20:40
09/27/17 20:40
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
In the opening post, you said "CapitalClosed". I don't think this is a real variable.

Capital is an input.

And here's a really good code snippet:
Code:
// reinvest the square root of your portfolio component profits, separately for long and short trades
if(GoLong) 
  Margin = OptimalFLong * Capital * sqrt(1 + (WinLong-LossLong)/Capital);else
  Margin = OptimalFShort * Capital * sqrt(1 + (WinShort-LossShort)/Capital); 
// reinvest the square root of your portfolio component profits
Margin = OptimalFLong * Capital * sqrt(1 + ProfitClosed/Capital); 
// reinvest the square root of your total profits
Margin = OptimalFLong * Capital * sqrt(1 + (WinTotal-LossTotal)/Capital);



Source: http://www.zorro-trader.com/manual/en/optimalf.htm

Re: Capital does not change with trades being closed? [Re: AndrewAMD] #468275
09/27/17 21:12
09/27/17 21:12
Joined: Sep 2017
Posts: 235
H
Hredot Offline OP
Member
Hredot  Offline OP
Member
H

Joined: Sep 2017
Posts: 235
Oh, I typed it wrong in the forum, but I meant profitClosed, sorry about that.
Indeed, that code snippet is what I was looking for, thanks for pointing it out!

Last edited by Hredot; 09/27/17 21:13.

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1