Creating an expert Advisor for the MT4 trading platform.
The expert’s course of action was as follows:
1. the Expert Advisor checked The accountfreemargincheck function for the sufficiency of funds for a sell order with a volume of 0.02, and upon successful verification, sent a sell limit order with a volume of 0.02.
2. by the time the open price of the sell limit order with a volume of 0.02 was reached, the funds were insufficient and the server deleted this order.
In the tester it looks like this:
How to get rid of such warnings in the tester, and then the moderator does not miss the expert in the market?
Or is it necessary to check the sufficiency of funds for pending orders in each tick and delete them yourself?
Sufficient funds for a pending order.
Share
vitalys
Thanks! I’ll try.
alexeyvik
The simplest thing is to avoid placing two orders at the same price. And if it is so conceived according to the strategy, check the sufficiency of funds taking into account two orders at the same price. And the check should be done not only before placing an order, but also during modification.
vitalys
I have the same situation in MT5. When the delay is triggered and a position is opened, the tester-terminal with matyukami deletes the order.
I prescribed the deletion of one order when opening a position, but the strategy is modifying orders and there are two orders at the same price, and the adviser can no longer delete the second order, because it is already on the server.
Question: in this case, how to solve the issue of checking funds?
vladon
it’s not about how the issue is resolved with the margin between the advisors, but rather that this is a completely understandable reason for removing the order
but in the market they do not want to admit this mistake and say: delete the orders themselves if the margin is not enough.
I. e. in other words: there is not enough margin delete all orders and tell the buyer “SHISH” there is no MARGIN I will not WORK”
mikalas
This issue is resolved through the global variable of the terminal, which is accessed by all expert advisors.
sandex
But the margin may not come, what then, to fend off dissatisfied buyers.
vladon
the same situation, the moderator does not want to accept the product because of this error, says-change the logic, delete the orders if they are not needed. but how to remove if the strategy they should stand? and the margin can come later, when the previous position is closed? how did you resolve this issue with the moderator?
alexeyvik
No arguments will help. I also went through this procedure. They do not understand that there are no functions in mql4 that are available in mql5. The answer is one: “there should be no Mistakes…” and that’s it…
True, I have an adviser Martin and the lot there was far from 0.02 and therefore checking AccountFreeMarginCheck () helped.
Probably the most reliable option, in this case, the test to do with a lot (lot+minimalnaya) or really trade a smaller lot.
komposter
Describe the situation to the moderator.
You can’t calculate the margin you need in the future with 100% accuracy. And there is no need to delete the order manually.
And if it stops because of tyranny, put a patch for checking in the market (for example, a deliberately smaller lot during the test).
dmitrievsky
Well, check the sufficiency when approaching the order, for a couple of points. If there is not enough, then delete it.