Question about Money management on MetaTrader platform

ukt

Junior member
20 0
Hello - hope this is correct spot to ask.. if not please advise and I'll delete and repost where suggested.

My trading environment is MetaTrader 4 but I believe question is general enough to perhaps apply to other trading platforms where coding is used.

Summary/background of question is this:
I believe, due to the single threaded nature of MT4 regards trading operations, that there are those that get around this issue by running one ClientTerminal for each chart symbol/timeframe and apply the expert to it.
In this way each expert runs solo and will not be constrained by the one trading thread issue due to other competing experts also wanting to trade ASAP.
This however raises money management issues which I hope are set out clearly below.
Thanks for reading!

I need some understanding on how some of you who run many ClientTerminals - all same expert and some/all using same account# deal with eg, daily draw down limit, maximum money risk, ...

On single Client, one way to deal with each expert's 'slice of the money cake' if 2 or more on same ClientTerminal/account# could be:

dMyMoneySlice = dEquity*dRiskPcent/dCountOfTradingExperts; //GlobalVariable

This basic idea (or variant of), I am happy with...

?what about when we introduce say 2 ClientTerminals running same/one expert on same account#.

As I understand it, we have 2 experts which do not 'know' about each other. RiskPcent must be divided by 2 (in this example).

So how achieve in an n ClientTerminal environment? and additionally, experts could stop/restart at any time etc. NOTE:This is not an issue in the one ClientTerminal example, as each instance would obviously be updating their local copy of 'count' or whatever mechanism is chosen - as long as they are dynamically aware of the changed 'count'..

external var is static and unable to react to changing number of experts running so would appear to not offer solution.. and file sum store seems slow and potentially? R/W contentions and delays, may emerge..
 

wackypete2

Legendary member
10,229 2,055
I need some understanding on how some of you who run many ClientTerminals - all same expert and some/all using same account# deal with eg, daily draw down limit, maximum money risk, ...

Each expert needs a unique OrderMagicNumber() that would be attached to each trade. This way each expert can keep track of only it's own trades and be completely detached from other experts in the same terminal. There are a few issues to be aware of using several experts on the same account whether in the same terminal or copy terminals. For instance if you have 10 experts all running completely detached from each other's results and each expert has a maximum allowable draw down (withing it's OWN trades) of 20%, then @ 10 x 20% = blown account. Each expert MUST be aware of the total equity in the account in order to avoid this. In that respect they cannot all be truly detached no matter how you set it up because they are all running within the same account and equity.

Peter
 

ukt

Junior member
20 0
@wackypete2
Thank you for informed reply. Will take comment on board and get a workable solution..
Perhaps having 5 experts on one terminal is not a big deal?

In principle seems good idea to allow any expert to do trade prospecting leading to trading without having to be 'delayed' by single trade thread of terminal.. hence say, 5 terminals with one expert each ALL free to trade away!
However, a proportional %risk [I guess] could be 'given' to each terminal expert via external i/p, what think about that or?

Presently in the one terminal setup, I use a global variable/semaphore which each expert must acquire prior to doing any lots, margin etc, calculations leading to actual OrderSend(). Only then is the semaphore released.
The side effect is that others wanting to trade at the same time must wait - but this is no different than the terminal's single trading thread imposed on all experts.
I have latitude of n ticks during which the trade will be considered 'still valid' and anyway, I use buy,sell stop orders which is additional help.

My extra 'layer' is just there to prevent any other expert from altering the account data which could invalidate another expert's lots and margin calcs.
I am concerned that MT 'could' change context to another expert that also wants to trade.

I do not have knowledge of how MT schedules experts but a system call could be a time for MT to swap context to another expert...

If this new expert modified account data via it's actions and then pre-empted expert finally gets context back, it most likely will have invalid lots or? as it made calculations based on account data before the other expert's actions caused account data mods.

Anyway! above is my justification for having this "only semaphore owner can mess with trade order decisions .."

Any observations appreciated..
Cheers
 
 
AdBlock Detected

We get it, advertisements are annoying!

But it's thanks to our sponsors that access to Trade2Win remains free for all. By viewing our ads you help us pay our bills, so please support the site and disable your AdBlocker.

I've Disabled AdBlock