Trade copy ea - page 10

 

thanks for sharing. this is excellent.

have done a bit of work on the code tonight.

want to try to improve the speed of opening another trade.

trades open from 8-20 seconds at present.

 

Help required please

Firstly the generousity of the technically gifted on these forums in providing us with their creations free is very much appreciated

The instal one click vbs did not work .... I recieve the error message as shown in post 68

So I have had to load manually

As a test set up and before trying on existing accounts I have loaded 2 MT4 demo platforms onto the C drive

I have copied the 8 no .vbs files and the 2 no .bat files into each terminal folder .... is this where they are supposed to go ?

I have placed a copy of trade_sender ea in the expert folder of the terminal I intend to trade from and a copy of trade_copy ea in the terminal I want the trades to be duplicated to

I open the platforms, open the ea's onto a chart in each platform

I have configured the trade_copy ea with the Master and Slave directory paths

Local is set to True

I have all set to trade live, smiley face etc and the slave terminal chart shows the various comments ... on trade_copy I have the following ... %0.00 and reset score?= %0.00 .... is this correct ?

I have selected the lot size as it applies to the accounts

I now place a trade on the master ( trade_send ea terminal )

Nothing happens with the slave ( trade_copy terminal )

When I look in the Journal tab of the slave terminal it confirms the ea has loaded succesfully

When I look in the Experts tab of the slave terminal it shows the following which keeps scrolling and repeating

2011.01.20 09:27:26 trade_copy: invalid handle -1 in FileClose

2011.01.20 09:27:26 trade_copy: invalid handle -1 in FileClose

2011.01.20 09:27:26 trade_copy: invalid handle -1 in FileClose

2011.01.20 09:27:26 trade_copy: invalid handle -1 in FileClose

2011.01.20 09:27:26 trade_copy EURUSD,M15: C:\Alpari Demo Master\experts\trade_sendtc_objects.csv

2011.01.20 09:27:25 trade_copy EURUSD,M15: C:\Alpari Demo Master\experts\trade_sendtc_trades.csv

2011.01.20 09:27:24 trade_copy EURUSD,M15: C:\Alpari Demo Master\experts\trade_sendtc_history.csv

2011.01.20 09:27:03 trade_copy: invalid handle -1 in FileClose

2011.01.20 09:27:03 trade_copy: invalid handle -1 in FileClose

What is this?

Can anyone help with this and anything else I may have done incorrectly so I can get this to work

Really appreciate anyones help

Thanks

 

Fast copying

BTW you guys assume its required that you wait for a tick, but it isn't

You can block on an open socket and return as soon as data is available if you are using a suitable server that sends the LENGTH of the data to follow.

I have a socket based to a 'publishing' ea i have that can round trip (message from server to EA AND back to server) in 1-2ms (yes ! milliseconds)

There are issues - when MT4 wants to close down it attempts to tell the the EA which may be blocked in a read - so it could eventually "turn off" the EA and will not send further ticks. This can be mitigated by implementing a "heartbeat" message that unblocks the EA so it can check the IsStopped on each cycle. (you have about 2.5 seconds to respond)

Its not foolproof (yet). There are other complications but i can copy as fast as i can detect new positions (a few hundred ms) in the source and get the instructions to the broker in the target (who knows)

 

for starters this directory is incorrect

C:\Alpari Demo Master

the correct directory is this

c\metatrader\trade_copy

c\metatrader\trade_sender

you shouldnt need to change any settings, use defaults

post 1 has a link to the post with instructions

https://www.mql5.com/en/forum/180349/page3

extract metatrader.zip to c drive

jcs:
Firstly the generousity of the technically gifted on these forums in providing us with their creations free is very much appreciated

The instal one click vbs did not work .... I recieve the error message as shown in post 68

So I have had to load manually

As a test set up and before trying on existing accounts I have loaded 2 MT4 demo platforms onto the C drive

I have copied the 8 no .vbs files and the 2 no .bat files into each terminal folder .... is this where they are supposed to go ?

I have placed a copy of trade_sender ea in the expert folder of the terminal I intend to trade from and a copy of trade_copy ea in the terminal I want the trades to be duplicated to

I open the platforms, open the ea's onto a chart in each platform

I have configured the trade_copy ea with the Master and Slave directory paths

Local is set to True

I have all set to trade live, smiley face etc and the slave terminal chart shows the various comments ... on trade_copy I have the following ... %0.00 and reset score?= %0.00 .... is this correct ?

I have selected the lot size as it applies to the accounts

I now place a trade on the master ( trade_send ea terminal )

Nothing happens with the slave ( trade_copy terminal )

When I look in the Journal tab of the slave terminal it confirms the ea has loaded succesfully

When I look in the Experts tab of the slave terminal it shows the following which keeps scrolling and repeating

2011.01.20 09:27:26 trade_copy: invalid handle -1 in FileClose

2011.01.20 09:27:26 trade_copy: invalid handle -1 in FileClose

2011.01.20 09:27:26 trade_copy: invalid handle -1 in FileClose

2011.01.20 09:27:26 trade_copy: invalid handle -1 in FileClose

2011.01.20 09:27:26 trade_copy EURUSD,M15: C:\Alpari Demo Master\experts\trade_sendtc_objects.csv

2011.01.20 09:27:25 trade_copy EURUSD,M15: C:\Alpari Demo Master\experts\trade_sendtc_trades.csv

2011.01.20 09:27:24 trade_copy EURUSD,M15: C:\Alpari Demo Master\experts\trade_sendtc_history.csv

2011.01.20 09:27:03 trade_copy: invalid handle -1 in FileClose

2011.01.20 09:27:03 trade_copy: invalid handle -1 in FileClose

What is this?

Can anyone help with this and anything else I may have done incorrectly so I can get this to work

Really appreciate anyones help

Thanks
 

question

I have downloaded the ea andinstalled it , everithing is fine ...

now my issue is this , i want the ea to copy the trades from the sender, but not delete the orders that are allready in place on the receiver . Is it any way around this?

 

how were the trades opened, that you wish to not be closed?

trade_copy only deletes trades that were opened from the sender, if you opened trades manually, them trades are not managed by the ea

also if the sender is closed while trades were open, them trades are not closed in trade_copy

if you login to a diferent account on trade sender, while trades were open, the slaves will never close them trades

before trade_copy can close a trade, these rules must be true

the file names set in trade sender match the names in trade copy

the magic number of the open trade in trade copy matches the ticket number in trade sender, and is in the order history

so, if you login to a diferent account in the sender, trades cannot be closed

though any new trades can be closed

the reason is because the old trades ticket number are not in the order history

therefore trade copy losses the ability to manage them trades

or, if you change the file names to use in the sender, trades cannot close them trades, becvause incorrect login

think of the file name setting, as a password

all of the rules above, also apply to objects, exept the history isnt checked

if you add a object to the chart manually, trade copy cannot delete nor move it

mihai27:
I have downloaded the ea andinstalled it , everithing is fine ... now my issue is this , i want the ea to copy the trades from the sender, but not delete the orders that are allready in place on the receiver . Is it any way around this?
 

not sure about the chart objects

i don`t know how the chart objects behave, but i know that in the moment i started the ea , all my open trades were closed , and new trades were opened at market price as it was on the server .

All my current trades have been closed instantly

 

i just tryed it again, and again, same story, closed everithing.

 

i dont realy understand what your saying, but heres what i learned through trying many different methods

if ever there is some error, mt4 doesnt seem to know how to handle it, it stops the ea from working until you do something

example, your internet had some error for a split second, or some ftp error

or the user changed the chart period while the ea was fetching data over the internet

my way around this is to not do things in the ea, so i used the java scripts

now if there is a error, the ea continues working

far as waiting on a tick, thats never bothered me

but im not closing trades in 1 pip profits either

i tried creating infinite loops, that would pause for a few miliseconds each loop

that didnt work for me, i think in mt4 you cannot uses infinite loops, theres some time out

mt5 has the ontime though?

not that im planning to ever code this in mt5, some1 else can

i do not plan to ever learn mt5 yet

ianj:
BTW you guys assume its required that you wait for a tick, but it isn't

You can block on an open socket and return as soon as data is available if you are using a suitable server that sends the LENGTH of the data to follow.

I have a socket based to a 'publishing' ea i have that can round trip (message from server to EA AND back to server) in 1-2ms (yes ! milliseconds)

There are issues - when MT4 wants to close down it attempts to tell the the EA which may be blocked in a read - so it could eventually "turn off" the EA and will not send further ticks. This can be mitigated by implementing a "heartbeat" message that unblocks the EA so it can check the IsStopped on each cycle. (you have about 2.5 seconds to respond)

Its not foolproof (yet). There are other complications but i can copy as fast as i can detect new positions (a few hundred ms) in the source and get the instructions to the broker in the target (who knows)
 

how were these trades opened?

mihai27:
i just tryed it again, and again, same story, closed everithing.
Reason: