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
4 registered members (AndrewAMD, EternallyCurious, TipmyPip, Quad), 899 guests, and 7 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
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