Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1536
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
So position opening-closing is displayed in any case. It should. It always has been. Until now.
Errors are not displayed/processed - that's why I wrote about the need to set the error returned by the server, and then think further. If it does not return errors, then it is a question of the EA logic - it may not work.
So opening-closing a position is displayed in any case. It should be displayed. And it has always been so. Until now.
It's sad. So much time and effort has already been put into this.... It's a shame. Perhaps there are ways to participate in trading without the broker layer. But I couldn't find anything on this topic.
I wish I had given up 10 years ago.
Try looking at the Moscow Exchange.
The code can be seen as text in google drive: https://drive.google.com/file/d/1bSmNjmO71GYO6fYVFioJWOsFctmmeJTy/view?usp=drive_link
Some evil coder has done a very bad job on the code of your Expert Advisor.
I am afraid that this EA will never be able to trade.
But seriously, the EA has no conditions for opening positions.
Agree that such a condition will never be fulfilled ask > ask and bid > bid as well.
And in your code, the EA is waiting for this very condition to be fulfilled.
Sorry, there is one condition that can open a sell position - ask0 > bid0, but the problem is that you can sell only at bid price, but your EA tries to sell at ask price, and naturally it gets requotes.
As you can see in the logs, everything is there.
Some evil coder really messed with your advisor's code.
I'm afraid that this EA will never be able to trade.
But seriously, the EA has no conditions for opening positions.
Agree that such a condition will never be fulfilled ask > ask and bid > bid too
And in your code, the EA is waiting for this very condition to be fulfilled.
Sorry, there is one condition that can open a sell position - ask0 > bid0, but the problem is that you can sell only at bid price, but your EA tries to sell at ask price, and naturally it gets requ otes.
As you can see in the logs, everything is there.
There are more evil coders than me...
How did you make the logs appear and what does this requote mean?
The thing is that there were no problems with opening orders. I attach a scan of the history for 03.05.2024. There are three positions opened by the robot, one of which is a buy.... I had to close them manually and remove the Expert Advisor from the page so that it would not open them again. For some reason, it was the closing condition that did not work.
I could post the whole code here, but there are two hundred lines of code. I'm not sure it would be right that way. That's why I left the link.
PS. I'm trying to add an mq5 file. You can see the code there too. My MetaEditor opens it.
Tried how the Expert Advisor, which is attached below, works. I opened a buy. Again did not close by the condition. And again there is no log file or entries in the Expert Advisor tab.
Errors are not displayed/processed - that's why I wrote about the need to set the error returned by the server, and then think further. If it does not return errors, then it is a question of the EA logic - it may not work.
You are right. I made prints and the log file appeared. But for some reason, it does not indicate the opening and closing of positions. Maybe I was worried for nothing? I'm sorry I wasted your time.
Perhaps this case.
I'm the angriest coder you'll ever find...
All right, everybody's got to start somewhere.
There are a lot of mistakes in the EA.
You should call PositionGetDouble after PositionSelect, otherwise your Price will most likely contain rubbish or zero, then you will compare this zero with ascii bits, and somewhere the condition will be triggered.
What does this code do?
It does the same thing a hell of a lot of times.
I think that the index of the mqlTick array should be i, not zero.
And I wrote about incorrect asci bits in position openings in the previous post.
You'd better not specify the price to open a position at all, let the CTrade class do it
This way you will have less chances to make a mistake.
When the condition bid0 > ask0 occurs, you want to open a position.
In my opinion, when this condition occurs, you should close all open positions, close the terminal and switch off the computer)))))
You should call PositionGetDouble after PositionSelect otherwise your Price will most likely contain rubbish or zero, then you will compare this zero with ascii bits, somewhere somewhere the condition will be triggered.
What does this code do?
It does the same thing a fuckload of times.
I think that the index of the mqlTick array should be i, not zero.
I wrote about incorrect asci bits in position openings in the previous message.
You'd better not specify the price for opening a position at all, let the CTrade class do it
This way you will have less chances to make a mistake.
When the condition bid0 > ask0 occurs, you want to open a position.
In my opinion, when this condition occurs, you should close all open positions, close the terminal and switch off the computer)))))
PositionSelect - I will have to spend a bit of time to understand why positions are not opened when I use it. So temporarily I use !PositionSelect(Symbol()) so that only one position on an instrument works at any time. That's why I think it's
works correctly. Checked. Or is that not always the case?
This code is timed, every 300 milliseconds, to find the first price for the period. That's why the index is 0. How else am I supposed to find the first price of the period?
The open buy price should be ask, as I understand it. And sell is bid. I guess I didn't write the position opening correctly. It's the other way round. Does it make no sense to write the instrument name when opening because of the class? Only the lottery and that's all?
Regarding the opening condition, I read that the spread can be negative. So I tried to provide for it, but I wrote the logic incorrectly. In fact, the spread can't be negative?
Anyway, thank you very much. I wouldn't have paid attention if you hadn't shown me.
Hello guys, can you please tell me what language I should learn in programming for MetaTrader 5?
Look at the top of this site, click on the link and start learning: