You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Where I made a mistake. Why do I get an enlarged position.
There is a concept called netting. According to the philosophy of NETTING, all unidirectional trades increase the position, while multidirectional trades close, decrease or reverse it.
If we draw a conclusion from the line, we understand that with an existing Sell a new Buy position will close or cut the existing position.
PS
By the way, TP and SL in MT5 are set according to the last trade, so they should be monitored too...
What is the correct way to delete all orders with a certain mode?
I have two functions for this, check_orders checks for orders with a certain mode, and remove_sl deletes them:
The problem is that in my EA's journal, I get lines like this:
2011.05.11 21:40:19 Trades '726238' : failed cancel order #4375237 buy 0.00 at 0.00000 [Invalid request]
I.e. unnecessary requests are sent to the trade server with a request to delete the order that has already been requested.
I need to go through the list of orders from top to bottom, e.g:
ЗЫ Если вы знаете инструмент то для поиска позиции совсем не нужно перебирать все позиции, достаточно воспользоваться вот этой функцией:
Thank you. I'll give it a try.
By the way, I use one symbol.
According to the philosophy of this very NETTING, all unidirectional trades increase the position and multidirectional trades close, decrease or reverse.
Exactly!
We conclude from the line we understand that with an existing Sell a new Buy will close or trim an existing position.
PS
By the way, TP and SL in MT5 are set according to the last trade, so they should be monitored too...
From your words, Mr.Interesting , I understand that I understand everything correctly.
I am using the same lots. I am using the same stops. Everything is as it should be. But something is wrong!
Okay. Promised to do two EAs and show the difference. I'll do it. I don't want to put the best one out there for everyone to see.
So, who among the respected experts can I email two EAs for the same strategy on mql4 and on mql5?
I just need to figure out what I'm doing wrong, that's all. Well, different price statistics can not change the test results by 2-3 times. It's about programming.
Lizar,Renat,sergeev, HELP me. I can give you all the experts to review the code. The Expert Advisor is simple but effective. I can still improve it, but I have simplified it to the maximum, to make the essence of the problem clearer.
I also apologize to everyone for being intemperate in their statements. I'm embarrassed. But I VERY much want to understand everything!
Need to go through the list of orders from top to bottom, e.g. like this:
Doesn't help, apparently the order is deleted successfully and then another request is sent:
2011.05.12 16:42:57 Trades '726238' : cancel order #4388299 buy stop 0.02 EURUSD at 1.41700 done
2011.05.12 16:42:57 Trades '726238' : cancel order #4388299 buy stop 0.02 EURUSD at 1.41700
2011.05.12 16:42:58 Trades '726238' : failed cancel order #4388299 buy 0.00 at 0.00000 [Invalid request] - already a buy while buy stop was
similar, but on mql4:
Well, look and compare. I messed up somewhere... The difference is substantial.
Doesn't help, apparently the order is deleted successfully and then another request is sent:
2011.05.12 16:42:57 Trades '726238' : cancel order #4388299 buy stop 0.02 EURUSD at 1.41700 done
2011.05.12 16:42:57 Trades '726238' : cancel order #4388299 buy stop 0.02 EURUSD at 1.41700
2011.05.12 16:42:58 Trades '726238' : failed cancel order #4388299 buy 0.00 at 0.00000 [Invalid request] - already a buy while buy stop was
I am ashamed to admit that I still have not mastered the art of telepathy.
I will repeat the question:
How do I correctly delete all orders with a certain mag?
I have two functions for this, check_orders checks for orders with a certain mode and remove_sl removes them:
The problem is that in EA's journal these lines appear:
2011.05.11 21:40:19 Trades '726238' : failed cancel order #4375237 buy 0.00 at 0.00000 [Invalid request]
I.e. unnecessary requests are sent to the trade server to remove the order the request to remove which had already been sent.
You have advised the following:
You need to go through the list of orders from top to bottom, for example like this:
I tried to do as you said, but the problem remains - the pending order is deleted first, then another request is sent to delete the same order. Here is an example of the log lines:
2011.05.12 16:42:57 Trades '726238' : cancel order #4388299 buy stop 0.02 EURUSD at 1.41700 done - successfully deleted the order
2011.05.12 16:42:57 Trades '726238' : cancel order #4388299 buy stop 0.02 EURUSD at 1.41700 - Another request is being sent
2011.05.12 16:42:58 Trades '726238' : failed cancel order #4388299 buy 0.00 at 0.00000 [Invalid request] - it was buy for some reason.
This does not happen every time, but sometimes, and it does not affect the Expert Advisor's operation. I just want to do everything correctly, not to load the trade server with empty requests, and to sort out the problem.
Thank you for your replies and your willingness to help.