1 (edited by William Tan 2021-10-07 03:30:33)

Topic: Buy orders made with TP price lower than open price

I applied 10 robots to one of my MT4 account as a single batched mq4 file. Somehow the orders' prices are weird.

1. 8 of them has negative TP price, which means the take profit target has a deficit price
2. 2 of them has too high TP (just my assumption when I compared to the CL price of those 2 orders)
3. The orders are closed either because of the "negative TP price" or "haven't reached the CL price yet"

You can see the trade history in the attached png file.
Is there something wrong with how I put the robots? Do I have to allow DLL or allow modification of Signal settings?

Post's attachments

Portfolio Expert EURGBP M15.mq4 41.34 kb, 2 downloads since 2021-10-05 

Screen Shot 2021-10-05 at 09.34.06.png 82.14 kb, 1 downloads since 2021-10-05 

Strategy Collection EURGBP M15.json 50.62 kb, 5 downloads since 2021-10-05 

You don't have the permssions to download the attachments of this post.

Re: Buy orders made with TP price lower than open price

I checked your collection and it looks ok. Please run it in the MT tester to see the SL and TP.

3 (edited by William Tan 2021-10-07 03:30:17)

Re: Buy orders made with TP price lower than open price

Thanks Popov. If I run it in MR strategy tester, setting the start date as the date I put the EAs and end date as today, there was no trade done. I tested again but starting with earlier date and it shows profitable trades.

I have checked the "journal" and indeed it is making a trade with deficit TP. I have added the journal and experts log.

Do you have any lead as to what the root cause might be? Could it be the broker or VPS?

Post's attachments

Screen Shot 2021-10-07 at 09.18.15.png 149.38 kb, file has never been downloaded. 

Screen Shot 2021-10-07 at 09.18.46.png 92.21 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: Buy orders made with TP price lower than open price

I tested your expert and see it works fine.

How much is your spread?

Set it to 10 pips in the tester and try it again.

The TP for the Long position is the current BID + TP Pips. It looks like the spread is much higher than the TP and eats its profit. This is highly unusual. The Long position opens at Ask price. Somehow Ask is higher than Bid + TP.

Post's attachments

mt-tester-graph.png 17.3 kb, 1 downloads since 2021-10-07 

mt-tester-journal.png 53.44 kb, file has never been downloaded. 

mt-tester-settings.png 23.91 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

5 (edited by William Tan 2021-10-07 04:58:43)

Re: Buy orders made with TP price lower than open price

My normal spread for EURGBP should be 30, for the backtest I also set it to 30 and it works fine (showing expected profits). Noted for the logic as well as why this should be an unusual case.

I am currently testing to run it in another VPS, hopefully it might somehow reduce this anomaly.

Also so far there were always quite big differences in the trades between live trading and the trades in the test.
For example:
1. If today is 1st Sep, and I run the EAs from 1 - 15th Sep. (normal spread 30)
2. Two weeks later at 15th Sep, I run backtest for the EAs with spread 30 for 1 - 15th Sep (same trading period as no 1)
The trades executed will be very different.

Anyway I have one last question Popov, in the journal you attached, why were the trades closed without reaching either TP or CL price? I have a few trades with similar behaviour (I think it's not caused by trailing CL)

Re: Buy orders made with TP price lower than open price

> Anyway I have one last question Popov, in the journal you attached, why were the trades closed without reaching either TP or CL price?

The only reason is that the strategy closes the position according to the Exit logic rules.
( At the end of the test MT closes all strategies. EA Studio can be setted to do it or not )

...

Be aware of correlated strategies in your portfolio.

Post's attachments

correlated-strategies.png 153.24 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: Buy orders made with TP price lower than open price

I see, noted for the close trades at the end of test.

Noted for the correlated strategies, at first I remove both for correlated graph line and rules similarity. But for those EAs I only remove the strategy if the rules are similar (thinking graph line shouldn't be bothered if it still has good line as long as the strategy is different). I will do more research and testing regarding this.

Thanks Popov.

8 (edited by William Tan 2021-10-08 19:09:27)

Re: Buy orders made with TP price lower than open price

Dear Popov,

I am sorry to bother you. I am a programmer as well, but I am having weird output when I tried to modify the trade logic inside the hedged EAs exported from portfolio.

For example, I tried to add these logic inside the "OpenPosition" function, I wrap the "if(IsTradeContextFree())" with:
1. if(takeProfit < 0)
2. if(takeProfit == 0)
3. if(takeProfit > 0)

All three of them doesn't affect anything when I update the EA and re-run the backtest. I also tried to modify the validation to be inline validation using &&, eg. "if(IsTradeContextFree() && takeProfit > 0)" as well as == 0 and < 0. But modifying it this way made the EA don't trade at all.

So I am a bit confused about the logic, and if it is possible for you, could I request you to give me a snippet code that I can append to my hedged mq4? Or maybe modify the mq4 that I attach here, and I can follow it for other mq4 I exported.

I am trying to add a validation before the EAs can open trade. And I think there is also logic to modify trades, although I don't know when the modification logic will be called.

But in the end, what I need is all the trades that the EA make, need to satisfy these rules:
1. The price between open price and take profit price must be above or equal X value (or -X if sell order).
2. The spread value when trying to open the trade must be between X to Y value.


UPDATE
Nvm Popov, I have got it done. Thanks

Post's attachments

m15 12.mq4 89.67 kb, 1 downloads since 2021-10-08 

You don't have the permssions to download the attachments of this post.