Sell now bug
-
I'm testing a bunch of EAs in a small live account and encountered a problem with Sell now. It apparently doesn't check to see if there's enough free margin before placing a trade.
With a number of already open positions I started getting emails on MT4:Subject: Trade could not be completed due to Insufficient Margin
Failed Trade: Type: SellMarket Symbol: EURJPY Units: 1000That message was sent four times, probably because Sell now tried to place the order repeatedly.
After a few minutes one of the previously open positions from another EA was closed and margin was freed up. Then three EURJPY orders opened, presumably from the earlier attempts. Not good, especially on a FIFO account.Would it be possible to have Buys and Sells check margin before placing an order? And perhaps check any error returns so unintentional orders aren't opened?
Triggering error messages from the broker is probably never a good thing.
Thanks
-
@richard96816 I do this way, maybe there is something better

-
@ambrogio Thanks for your response.
I'm using the Risk % of Margin feature in the Buy and Sell blocks. That's one of the main reasons for using a system like fxDreema. I can and have written all that stuff myself, but it's messy and unnecessary if the one in this system does the whole job.
It admittedly buries lots of details, but that's what you want. An assurance that all issues surrounding correct risk assessment and order placement are handled. MT4 has a single function call to check for sufficient margin. But you can't use it very effectively with fxDreema's Buy now and Sell now unless you duplicate almost everything they do. It's all buried and you only get to see the results.
Do I need to write my own Buy/Sell now? I consider it the core of the system and its correctness to be more important than almost anything else.
The fact that users are simply programming around these bugs is not a good sign.
-
@ambrogio I don't see any accounting for stop-loss in your scenario. There are other things missing too, I think.
-
@richard96816 I just wanted to show the formula I use, it's not a complete job.
As for your request, perhaps it is better to ask directly to the adm. @fxDreema -
@ambrogio I didn't mean to seem overly negative, just constructive.
I wish more folks would report bugs rather than just working around them. We're the testers. If we don't share what we see then the product will never get better.
Thanks again for your help.
-
@richard96816 Oh, no problem, it's alright