Gamestudio Links
Zorro Links
Newest Posts
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (EternallyCurious, RealSerious3D), 779 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 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,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
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,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
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