Total different performance of exactly same EA on different brokers.

Jul 28, 2010 at 07:04
Przeglądane 4,153
22 Replies
salmas64
forex_trader_12364
Uczestnik z May 26, 2010   5 postów
Jul 28, 2010 at 07:04 (edytowane Jul 28, 2010 at 07:10)
Hello programmers,

I'm newbie with programming EA.

I'm using my own EA and Ive made test to run same EA with same setting on few different brokers demo accounts.

EA on 2 brokers runs very similar in profit but on another 2 brokers runs completely different and to my surprise got 2 negative results and totally different. I've started them in same time on same balance and as far I know spreads are very similar on tested brokers.

Can anyone experienced advise me, what could cause this differences? That exactly same EA on same conditions with different broker gives completely opposite results?

My EA uses OrderProfit()+OrderSwap() functions to determine profit for each trade. Is it possible that different brokers can 'trick' EA and give different results?

1. Broker Feeds?
2. Broker Spread?
3. Broker native currency?
4. Account currency?

regards,
Slavo


Elkart
forex_trader_7
Uczestnik z Aug 01, 2009   941 postów
Jul 28, 2010 at 07:49 (edytowane Jul 28, 2010 at 07:50)
For starters I know for a fact the back office of MT4 can and I quote ' make life difficult for you'.

At the very least a broker can influence the volatility of your feed. But is suspect it goes a lot further than that. Remember the average MT4 broker budgets on your failure. If you don't fail they will help you along a little....

Are there any time functions in your EA? For example if you use pivots, each broker going to give you a different value. Also indicators that are volume based will be inaccurate as every broker will give you a different volume reading.

In Mt4 the volume is in fact tick volume for that broker and has nothing to do with actual volume traded.

So there's a just a few reasons. I can think of a dozen more.....
Uczestnik z Oct 28, 2009   1435 postów
Jul 28, 2010 at 08:12
Yep, I would need to know more about the way your EA works. However if it's scalping or has tight stops then you could expect very different results. Spreads and prices around news events can vary considerably between different brokers. They might be requoting you or throwing you old tick messages. Could be any number of reasons to be honest, depending on how the EA works.
11:15, restate my assumptions: 1. Mathematics is the language of nature. 2. Everything around us can be represented and understood through numbers. 3. If you graph these numbers, patterns emerge. Therefore: There are patterns everywhere in nature.
Uczestnik z Aug 20, 2009   266 postów
Jul 28, 2010 at 08:14 (edytowane Jul 28, 2010 at 08:14)
Apart from that, I have one more word for you..........FILLS.

I have seen the same broker, running the same EA on 2 live accounts from the same VPS have different results.

Unfortunately a broker does not operate on the WYSIWYG(what you see is what you get) priciple like a good computer program, nor is it like a supermarket where you can just pick up any quantity of produce at the displayed price like the next shopper.

I always think of it as a big sign outside a store that says 'Price 1.64.....while stocks last'. This means that if I pick up an order, 1 ms(yup 1 thousandth of a second) before you do, you get whats left, not what you ordered.
Wealth Creation Through Technology
Elkart
forex_trader_7
Uczestnik z Aug 01, 2009   941 postów
Jul 28, 2010 at 08:16
Kenny,

You sell it back then during the next 1 ms?
Uczestnik z Aug 20, 2009   266 postów
Jul 28, 2010 at 08:36
Ya boet, I run off cheap computers that can't do that, but I like the way you think. No wonder banks will spend millions to shave 1 ms off their latency.

Wealth Creation Through Technology
salmas64
forex_trader_12364
Uczestnik z May 26, 2010   5 postów
Jul 28, 2010 at 09:19 (edytowane Jul 28, 2010 at 09:28)
Thanks for ideas. Hmm.... it seems to the world of MT4 is less ideal that I thought 😕

My EA works on idea of martingale system, but if case of larger movement of the market it opens hedges for some trades to protect equity. EA calculates combined profit for all opened BUY and SELL positions and if reaches 'Target combined $ profit' or 'Target Stop loss $ profit' closes all trades immediately with minimal slippage as possible.

EA calculates profit for each trade the way ( OrderProfit()+OrderSwap() ) so I believe this should be independent from broker's feeds. And big differences on balance I'm getting after closing those trades on some broker getting negative trend. 😞

Example: EA has open 30 trades (buys and sells) of size 0.01 lot and current combined profit is +$20.00.

After closing all 30 trades getting differences on closed trades:
Broker 1 = +$18.30
Broker 2 = +$17.80
Broker 3 = +$12.20
Broker 4 = -$2.20

I don't think that this is caused by slippage and different spread. That would be too high and I think EA calculates somehow differently on each broker the 'Combined profit' or is idea of combining trades bad way of trading? This is still on demo accounts, now I can imagine how it would be worse on real accounts.

Actually I'm not sure what is the real unit for OrderProfit() is it in traded currency, deposit currency or broker currency? See attached definition from MQL4 help, it's not quite clear to me.



Elkart
forex_trader_7
Uczestnik z Aug 01, 2009   941 postów
Jul 28, 2010 at 09:22
Ya boet hey Kenny?

I put that into google translator and it tuned me you're a rock ek se....
Uczestnik z Aug 20, 2009   266 postów
Jul 28, 2010 at 09:57
Ya, nee, I'm a yaapie, but at least from the right side of the railway tracks.........

Slavo,

If you are closing 30 orders, I am not surprised you are getting slippage and spread changes. You say that your EA closes all trades with minimal slippage.....care to elaborate on how it does that? As far as I know you cannot control slippage. Perhaps you should get your EA to record the Bid/Ask and then calculate your total slippage.......I think it may be an eye opener. And, yeah, I think you may have come across the fact that not all brokers are the same.

OrderProfit() is in deposit currency. It is the number that you see in the Profit column of the terminal.
Wealth Creation Through Technology
Uczestnik z Oct 28, 2009   1435 postów
Jul 28, 2010 at 10:19
Indeed, as MT4 EA's can only handle one thread with the broker at any one time you're going to be getting new prices all the time while your stack of orders closes. You might want to think about running separate MT4 instances for separate pairs in order to reduce this problem. Not sure how that would work out with your strategy but it's something you may want to consider.
11:15, restate my assumptions: 1. Mathematics is the language of nature. 2. Everything around us can be represented and understood through numbers. 3. If you graph these numbers, patterns emerge. Therefore: There are patterns everywhere in nature.
Uczestnik z Sep 04, 2009   879 postów
Jul 28, 2010 at 10:23 (edytowane Jul 28, 2010 at 10:24)
salmas64 posted:
    Thanks for ideas. Hmm.... it seems to the world of MT4 is less ideal that I thought 😕

My EA works on idea of martingale system, but if case of larger movement of the market it opens hedges for some trades to protect equity. EA calculates combined profit for all opened BUY and SELL positions and if reaches 'Target combined $ profit' or 'Target Stop loss $ profit' closes all trades immediately with minimal slippage as possible.

EA calculates profit for each trade the way ( OrderProfit()+OrderSwap() ) so I believe this should be independent from broker's feeds. And big differences on balance I'm getting after closing those trades on some broker getting negative trend. 😞

Example: EA has open 30 trades (buys and sells) of size 0.01 lot and current combined profit is +$20.00.

After closing all 30 trades getting differences on closed trades:
Broker 1 = +$18.30
Broker 2 = +$17.80
Broker 3 = +$12.20
Broker 4 = -$2.20

I don't think that this is caused by slippage and different spread. That would be too high and I think EA calculates somehow differently on each broker the 'Combined profit' or is idea of combining trades bad way of trading? This is still on demo accounts, now I can imagine how it would be worse on real accounts.

Actually I'm not sure what is the real unit for OrderProfit() is it in traded currency, deposit currency or broker currency? See attached definition from MQL4 help, it's not quite clear to me.






Its order execution delay and slippage what causes the differences. Check it in the journal. One of the reasons can be the broker latency.
salmas64
forex_trader_12364
Uczestnik z May 26, 2010   5 postów
Jul 28, 2010 at 10:30
Thanks Kenny.

Closing 30 trades takes about 1-5 seconds, it seems to me pretty fast. Maximum within 1-3 ticks, that's why I think can't be caused by spread 😞

Minimal slippage I managed to do via recursive loop with increasing slippage value.

In other words:
         EA tries to close trade with slippage 0. if fails
                          tries again with slippage 1. if fails
                          tries again with slippage 2. if fails
                          tries again with slippage 3. if fails
                          .........
                          until trade is closed successfully.
Uczestnik z Oct 28, 2009   1435 postów
Jul 28, 2010 at 10:34 (edytowane Jul 28, 2010 at 10:37)
Not sure why you are doing it this way. Provided you have an honest broker submit it with a maximum slippage and if it can't close with no slippage then it will close with slippage.

In fact thinking about it further at the point you submit the request to close with zero slippage they might not be able to close at zero slippage.
When you then submit your request to close with 1 pip slippage they might actually be able to close with zero slippage etc.

Whenever I code EA's I always try and strip out any code that is not absolutely necessary. The more code you put in there the more there is to go wrong and to hold things up.
11:15, restate my assumptions: 1. Mathematics is the language of nature. 2. Everything around us can be represented and understood through numbers. 3. If you graph these numbers, patterns emerge. Therefore: There are patterns everywhere in nature.
Uczestnik z Aug 20, 2009   266 postów
Jul 28, 2010 at 10:47 (edytowane Jul 28, 2010 at 10:47)
Slavo,

I'm inclined to agree with Steve. Slippage is a parameter that you can use to give yourself a choice of accepting a fill or not. Once you have decided to close a string of orders, you are actually committed to accepting whatever fill you get by your strategy...............changing the slippage does not improve the fill that you receive.

A normal broker will not look at your slippage before 'getting' you a price. They will find you a price and then they will look at the slippage parameter to determine whether to accept or to re-quote.

You should also tell me which broker you are with, as to be quite honest, 1 - 5 seconds to close 30 trades seems beyond belief. I would be interested to see that close routine. Do you use OrderCloseBy()?
Wealth Creation Through Technology
Elkart
forex_trader_7
Uczestnik z Aug 01, 2009   941 postów
Jul 28, 2010 at 10:52
Kenny,

I can't get over a transaction a second. Mostly because all the crap we had to write in to double check everything's happening as it should. Mt4 not the best piece of software around.

Have to write all the issues out and that takes time to check.
Elkart
forex_trader_7
Uczestnik z Aug 01, 2009   941 postów
Jul 28, 2010 at 10:56
Saying that, I did do 5000 trades yesterday in an hour. So I guess I shouldn't complain to much.
Elkart
forex_trader_7
Uczestnik z Aug 01, 2009   941 postów
Jul 28, 2010 at 11:06
Not that I wanted to mind you. Fat fingers, but old MT put it out there and Go markets took it without as much as a squeal...
Uczestnik z Aug 20, 2009   266 postów
Jul 28, 2010 at 11:59 (edytowane Jul 28, 2010 at 12:02)
Actually just been running some tests. I have been eyeing out this OrderCloseBy() function for a while.

I don't do hedge Grid trading, but for those that are interested, here is some good ideas to pass on to your programmers....

There are 3 scripts attached to this post. Use the Open_Hedge_Trade script to open 30 trades on your demo account......make sure it is a big account cos it open 1 full lot per trade.

Run the Close_All script and note the time in the experts tab. Then Open the 30 trades again and run the Quick_Close script. Note the time in the experts tab. You will see the Quick_Close script closes all the trades about 50% - 100% quicker than the regular close script.

How does this work you ask? When a broker closes your trade he actually has to enter a trade for you in the opposite direction and this matching off take time. By using this OrderCLoseBy() function, you are telling the broker that there is a matching trade within your own account that you wish to close. This means that broker does not have to find a trading partner for you plus it kills 2 trades with 1 instruction.

Another benefit I can see here is that you would have no naked exposure in the market while you are closing one side of the hedge.

BTW, my times from my VPS were 6594 ms for the normal way and 4391 ms with the quick close. Also note the scripts are rough and dirty so there is no error handling and so on, they were just intended for demonstration purposes.

Załączniki:

Wealth Creation Through Technology
Uczestnik z Oct 28, 2009   1435 postów
Jul 28, 2010 at 12:08
Excellent work Kenny and well worth knowing
11:15, restate my assumptions: 1. Mathematics is the language of nature. 2. Everything around us can be represented and understood through numbers. 3. If you graph these numbers, patterns emerge. Therefore: There are patterns everywhere in nature.
salmas64
forex_trader_12364
Uczestnik z May 26, 2010   5 postów
Jul 28, 2010 at 15:34 (edytowane Jul 28, 2010 at 15:35)
Thanks Kenny that's very useful information. Honestly I don't understand mechanics what's happening on broker's side. Why he has to enter opposite trade when I'm closing trade? I thought broker is passing and leveraging my trade somewhere 'farther away' 😄. Does it work other way as well? What broker does when I'm entering new trade? Has he closes his existing trade in opposite direction?

I really didn't notice OrderCloseBy() function. 😄 Thanks for the examples, so far I used in closing routine similar way like in your Close_All script.
In my case I have mixed bag of BUYs and SELLs, but not always equal ratio, but I can use OrderCloseBy() for pairs and OrderClose() for leftovers.

You must be connected to Myfxbook in order to leave a comment
*Komercyjne wykorzystanie i spam są nieprawidłowe i mogą spowodować zamknięcie konta.
Wskazówka: opublikowanie adresu URL obrazu / YouTube automatycznie wstawi go do twojego postu!
Wskazówka: wpisz znak@, aby automatycznie wypełnić nazwę użytkownika uczestniczącego w tej dyskusji.