Hey guys, I wanted to put a post together to explain how partial closures work on the Simpletrader copier.
This only discusses how partials work from version 3.3 onwards. If you were using a copier on an earlier version than 3.3 then partials worked in a slightly different way.
- When the master opens a trade, we store the current balance and equity against the specific trade.
- If the master now decides to close a portion of this trade the copier notes this trade as a partial and notes the lots closed
- Simpletrader now sends the new lot size to the copier
The copier now takes over (EA)
- As an example, if the master had opened 1 lot, and has closed 0.5 - the new trade size is 0.5
- The copier does the same equation as when opening a new trade
We will assume:
Master Account
Balance: $10,000
Opened: 1 Lot
Closed: 0.5 lots
Remaining: 0.5 lots
Client Account:
Balance: $20,000
Risk: 1
Opened: 2 lots
In the case of using Risk Balance the client account now does this equation:
(Master Lots * User Multiplier) / (Master Balance Upon Open / Account Balance);
(0.5 * 1) / (10,000 / 20,000) = 0.5 / 0.5 = 1
Every time the EA is looping, its doing this equation to make sure that your lot size is still equal to the answer of that equation.
Things that make partials change
- Changing your multiplier while a partial is open will make that above equation change. For example, if you were to increase your multiplier to 2, that above equation changes...
(0.5 * 2) / (10,000 / 20,000) = 1 / 0.5 = 2
- So now the copier thinks the partial should be 2 lots... well its already only 1 lot in size, so nothing happens as we can't open more lots
- If you changed your multiplier to be smaller, lets say we changed it to 0.5 the equation changes again...
(0.5 * 0.5) / (10,000 / 20,000) = 0.25 / 0.5 = 0.5
- Soon as you change that multiplier, the EA now thinks your partial should be 0.5 instead of 1. So it will close out 0.5 lots....
- Lets say you increase your balance during a partial close, this is going to make the equation change again... Lets say we increase the balance from 20,000 to 30,000
(0.5 * 1) / (10,000 / 30,000) = 0.5 / 0.33 = 1.51
- Now the copier wants the current partial to be bigger than it currently is. Again this is impossible so it'll just sit waiting for the equation to drop below the current lot size or close.
- Withdrawing from your balance will have the opposite effect of the above - Lowering your balance, will make your partial equation smaller, and as such your partial is going to close out some of its lots.
- Changing your money management type. I.e. from risk balance to risk equity, or lot multiplier etc
- If you are using risk with equity - then if you continue to drop in equity, you will find that the equation wants to continually drop your lot size.
Why does the EA sometimes close multiple partials in 1 go?
We have actually found a way to change this and will be releasing this in version 3.6.
This is to do with how MQL4 normalizes lot sizes - but we've change the formula so this should no longer happen in 3.6. This isn't actually any detriment to the copier, but it is annoying as it makes it hard to compare trades between the master and copier.
Also note that sometimes the broker may decide to split your partial into multiple trades. This might be because the broker is struggling to close all the lots at the same time so splits the trade into multiple partials. I'm afraid there is nothing we can do about this, as that is broker side.
Limitations
Due to some limitations in MQL4 we have limited the speed in which it checks for partials. If a trade is opened and partially closed within 5 seconds - the copier will not class it as a partial trade, and as such will fully close the previous trade and reopen a new trade.
We do not see this as a problem in the real world as over 1 million live trades on our network, in % terms the likely hood of this happening is so slim its not a consideration.
If this were to happen, the client losses an additional spread.
Please note this is noted for transparency, however this is not something that we ever class as a limitation.
YOU CAN STOP READING - READ ON IF YOU WANT TO UNDERSTAND THE THOUGHT PROCESS BEHIND PARTIALS
Some of you may want to better understand the reason that we handle partials in the same way that we open a new trade. It would make more sense to simply look at the % change and use that to close out the slave side.
So in the case of 1 lot opening on the master, and 0.5 lots being closed - we could assume 50% of the trade is closed....
So if we had 0.1 lots on the slave, 50% of that is pretty simple.. 0.05.
In theory this works, however you have to bare in mind that the slave EA is a stateless entity - in that it only knows what to do based on what data we send it. We have always built the copier to be as light weight as possible. It may not look like it as we have such a feature full copier, but the key to speed is light weight! This is why our copier is still the fastest remote copier in the industry.
If we wanted to use a % of the master, then the copier needs to start informing Simpletrader about parts of the trades that it has closed. It then needs to pass that information back to the EA - all of this takes time. This also relies heavily on making sure the information stored and passed is correct.
The only way to handle % of partials is as follows:
- Store that data on simpletrader
- This uses extra bandwidth, extra calculations and simply more time. We are talking such small amounts of time, but the fact remains it still increases the amount of data sent back and forth
- Store the data in a file on the computer the EA is using.
- This has major drawbacks in that the file could become corrupt / you can't move your EA from 1 VPS to another without having to worry about additional files
- This is basically a no no
- There is no way to store the data inside the EA itself, as soon as you restart MT4 that data will be lost
As you can hopefully see, there are so many draw backs to trying to use a % based partial equation, that the way we do it now makes the most sense.
Over the past few months we have improved upon the design of the partial implementation. Previously (prior to 3.3) the partials were using live balance/equity from the master. This was no good when partials had been open months as the balance/equity of the master could have changed dramatically in that time.
This only discusses how partials work from version 3.3 onwards. If you were using a copier on an earlier version than 3.3 then partials worked in a slightly different way.
- When the master opens a trade, we store the current balance and equity against the specific trade.
- If the master now decides to close a portion of this trade the copier notes this trade as a partial and notes the lots closed
- Simpletrader now sends the new lot size to the copier
The copier now takes over (EA)
- As an example, if the master had opened 1 lot, and has closed 0.5 - the new trade size is 0.5
- The copier does the same equation as when opening a new trade
We will assume:
Master Account
Balance: $10,000
Opened: 1 Lot
Closed: 0.5 lots
Remaining: 0.5 lots
Client Account:
Balance: $20,000
Risk: 1
Opened: 2 lots
In the case of using Risk Balance the client account now does this equation:
(Master Lots * User Multiplier) / (Master Balance Upon Open / Account Balance);
(0.5 * 1) / (10,000 / 20,000) = 0.5 / 0.5 = 1
Every time the EA is looping, its doing this equation to make sure that your lot size is still equal to the answer of that equation.
Things that make partials change
- Changing your multiplier while a partial is open will make that above equation change. For example, if you were to increase your multiplier to 2, that above equation changes...
(0.5 * 2) / (10,000 / 20,000) = 1 / 0.5 = 2
- So now the copier thinks the partial should be 2 lots... well its already only 1 lot in size, so nothing happens as we can't open more lots
- If you changed your multiplier to be smaller, lets say we changed it to 0.5 the equation changes again...
(0.5 * 0.5) / (10,000 / 20,000) = 0.25 / 0.5 = 0.5
- Soon as you change that multiplier, the EA now thinks your partial should be 0.5 instead of 1. So it will close out 0.5 lots....
- Lets say you increase your balance during a partial close, this is going to make the equation change again... Lets say we increase the balance from 20,000 to 30,000
(0.5 * 1) / (10,000 / 30,000) = 0.5 / 0.33 = 1.51
- Now the copier wants the current partial to be bigger than it currently is. Again this is impossible so it'll just sit waiting for the equation to drop below the current lot size or close.
- Withdrawing from your balance will have the opposite effect of the above - Lowering your balance, will make your partial equation smaller, and as such your partial is going to close out some of its lots.
- Changing your money management type. I.e. from risk balance to risk equity, or lot multiplier etc
- If you are using risk with equity - then if you continue to drop in equity, you will find that the equation wants to continually drop your lot size.
Why does the EA sometimes close multiple partials in 1 go?
We have actually found a way to change this and will be releasing this in version 3.6.
This is to do with how MQL4 normalizes lot sizes - but we've change the formula so this should no longer happen in 3.6. This isn't actually any detriment to the copier, but it is annoying as it makes it hard to compare trades between the master and copier.
Also note that sometimes the broker may decide to split your partial into multiple trades. This might be because the broker is struggling to close all the lots at the same time so splits the trade into multiple partials. I'm afraid there is nothing we can do about this, as that is broker side.
Limitations
Due to some limitations in MQL4 we have limited the speed in which it checks for partials. If a trade is opened and partially closed within 5 seconds - the copier will not class it as a partial trade, and as such will fully close the previous trade and reopen a new trade.
We do not see this as a problem in the real world as over 1 million live trades on our network, in % terms the likely hood of this happening is so slim its not a consideration.
If this were to happen, the client losses an additional spread.
Please note this is noted for transparency, however this is not something that we ever class as a limitation.
YOU CAN STOP READING - READ ON IF YOU WANT TO UNDERSTAND THE THOUGHT PROCESS BEHIND PARTIALS
Some of you may want to better understand the reason that we handle partials in the same way that we open a new trade. It would make more sense to simply look at the % change and use that to close out the slave side.
So in the case of 1 lot opening on the master, and 0.5 lots being closed - we could assume 50% of the trade is closed....
So if we had 0.1 lots on the slave, 50% of that is pretty simple.. 0.05.
In theory this works, however you have to bare in mind that the slave EA is a stateless entity - in that it only knows what to do based on what data we send it. We have always built the copier to be as light weight as possible. It may not look like it as we have such a feature full copier, but the key to speed is light weight! This is why our copier is still the fastest remote copier in the industry.
If we wanted to use a % of the master, then the copier needs to start informing Simpletrader about parts of the trades that it has closed. It then needs to pass that information back to the EA - all of this takes time. This also relies heavily on making sure the information stored and passed is correct.
The only way to handle % of partials is as follows:
- Store that data on simpletrader
- This uses extra bandwidth, extra calculations and simply more time. We are talking such small amounts of time, but the fact remains it still increases the amount of data sent back and forth
- Store the data in a file on the computer the EA is using.
- This has major drawbacks in that the file could become corrupt / you can't move your EA from 1 VPS to another without having to worry about additional files
- This is basically a no no
- There is no way to store the data inside the EA itself, as soon as you restart MT4 that data will be lost
As you can hopefully see, there are so many draw backs to trying to use a % based partial equation, that the way we do it now makes the most sense.
Over the past few months we have improved upon the design of the partial implementation. Previously (prior to 3.3) the partials were using live balance/equity from the master. This was no good when partials had been open months as the balance/equity of the master could have changed dramatically in that time.
Comment