Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (SBGuy, Quad), 768 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Allocate Margin to asset portfolio #472607
05/07/18 23:12
05/07/18 23:12
Joined: Nov 2017
Posts: 34
C
Cheulmen Offline OP
Newbie
Cheulmen  Offline OP
Newbie
C

Joined: Nov 2017
Posts: 34
Hi, I’m not able to find anywhere how to allocate Capital to different assets while using loop(). I want to allocate the Capital to the first asset that is going to enterLong() according to some TA indicator. Until that trade exits, the other algos won’t have any money to trade. Then, when that first trade exits because a Stop or the exitLong(), the other algos will be able to use the money (as long as their indicator is hit). So, at any time, only one combination algo/asset will use all the money.

So for instance using a combination of 2 assets and 3 algos, how should I do that?
If doing this is not possible, how can I assign a fixed amount to each asset/algo? (so, in my example, how could I assign 100 to each one of the 6 combinations?)

void run()
{
Capital =600;

while(asset(loop(“EUR/USD”, “GBP/USD”)))
while(algo(loop("H1", "H2”, "H3”)))
{
Margin=Capital+ProfitClosed; //<—— How should I modify this??

if(indicator==1) //“indicator” will be filled somewhere
enterLong();
else
if (indicator==2)
exitLong();
}
}

I don't want to use FACTORS or OptimalF, by the way, I want all the assets to have the same importance. The workshop6 talks about capital allocation but it doesn't answer my doubts...

Re: Allocate Margin to asset portfolio [Re: Cheulmen] #472616
05/08/18 11:18
05/08/18 11:18
Joined: Aug 2017
Posts: 102
Spain
B
Brax Offline
Member
Brax  Offline
Member
B

Joined: Aug 2017
Posts: 102
Spain
Use a static var to lock the entry and exit condition.

static bool tradelock = false;

...

Margin = Capital+(WinTotal-LossTotal) //Total money in account

...

if(!NumOpenLong && indicator==1 && !tradelock)
enterLong();
tradelock = true;
else
if (NumOpenLong && indicator==2 && tradelock)
exitLong();
tradelock = false;
}

Last edited by brax; 05/08/18 11:22.
Re: Allocate Margin to asset portfolio [Re: Brax] #472618
05/08/18 13:34
05/08/18 13:34
Joined: Nov 2017
Posts: 34
C
Cheulmen Offline OP
Newbie
Cheulmen  Offline OP
Newbie
C

Joined: Nov 2017
Posts: 34
Oh, shame on me for not realizing before, that's a very easy solution laugh Thanks!


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1