Discussion of article "Step-by-Step Guide to Writing an Expert Advisor in MQL5 for Beginners" - page 30
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
Tester - "Unsupported filling mode"
Tried on 3 different brokers. Whats the problem?
Try to replace SYMBOL_FILLING_FOK with SYMBOL_FILLING_IOC.
Regards, Vladimir.
Hello everyone (Especially the dear author)
I coded along with this article. I enjoyed it a lot and learned a lot from it.
Thank you for writing such an informative article.
However I have a problem. My EA did not place any orders. I downloaded the author's code but it did not place any orders too.
Since the article is 13 years old, I assume that the code is now outdated. Can anyone help me out?
My code is in the file below. Thanks anyone in advance.
Visit the untranslated English page, which is the correct download.
Download from this page: Step-By-Step Guide to Writing an Expert Advisor in MQL5 for Beginners - MQL5 Articles
https://www.mql5.com/en/articles/100
Dear everyone;
From this article in the bottom,he has the complete code mlq5 to download.
I have download to check function and found that the program has incorrect algorithm.
Setup is EURUSD ,M1,100USD start on 2025/01/01 to 2025/01/31
First order is sell order,then later have many Buy order.
The concept is should have only one order but is occour from line 165
The flag to check now is have ordered or not is separate in 2 flag variable (Buy_opned,Sell_opened).
if now already have sell order,then on line 216 (Ordersend) will make new buy order even now is have sell order.
Wait for next candle Buy_open flag on statement of line 172 can not set to on again.Why ?. Because first order is sell ,second order is buy.
And yes Next candle again Buy order on line 216 (Ordersend) will occour and go on,many order buy order occour until no money.
See Chart here.
See Order list.
Thank you.
Niwath Jeamphue.
Dear everyone;
From this article in the bottom,he has the complete code mlq5 to download.
I have download to check function and found that the program has incorrect algorithm.
Setup is EURUSD ,M1,100USD start on 2025/01/01 to 2025/01/31
First order is sell order,then later have many Buy order.
The concept is should have only one order but is occour from line 165
The flag to check now is have ordered or not is separate in 2 flag variable (Buy_opned,Sell_opened).
if now already have sell order,then on line 216 (Ordersend) will make new buy order even now is have sell order.
Wait for next candle Buy_open flag on statement of line 172 can not set to on again.Why ?. Because first order is sell ,second order is buy.
And yes Next candle again Buy order on line 216 (Ordersend) will occour and go on,many order buy order occour until no money.
See Chart here.
See Order list.
Thank you.
Niwath Jeamphue.
You should not use PositionSelect(_Symbol) unless you are using a netting account.
On an hedging account, you need to select your position correctly, with PositionGetTicket() or PositionSelectByTicket(). Check the documentation.
You should not use PositionSelect(_Symbol) unless you are using a netting account.
On an hedging account, you need to select your position correctly, with PositionGetTicket() or PositionSelectByTicket(). Check the documentation.
Thank you for your comment. But I just want to tell everyone that the source code is from the final complete from this article.
https://www.mql5.com/en/articles/download/100/my_first_ea.mq5
Please try with yourself ,will be understand my mainpoint.
Thank you.
Thank you for your comment. But I just want to tell everyone that the source code is from the final complete from this article.
https://www.mql5.com/en/articles/download/100/my_first_ea.mq5
Please try with yourself ,will be understand my mainpoint.
Thank you.
This article is from 2010, at that time ALL accounts were netting accounts on MT5 including for Forex.
Hedging accounts where introduced in 2016 : https://www.mql5.com/en/articles/2299
Niwath Jeamphue #:
Please try it yourself, you will understand my point of view.
Thank you.
Hello. I understand your point of view. In the attached file I have changed the source code of the Expert Advisor so that only one position is opened, no matter what account you use - netting or hedge.
Regards, Vladimir.
Hello. I understand your point of view. In the attached file I have changed the source code of the Expert Advisor so that only one position is opened, no matter what account you use - netting or hedge.
Regards, Vladimir.
Hedge Account ,MrBrooklin . Thank you. But I prefer to get only on order,not so many orders.
I have been change algo. from original
Clear Buy and Sell open flag
If (PositionSelect(_Symbol)==true)
If found that is buy position then set Buy_opened flag
Else If found that is sell position then set Sell_opened flag
Zone1: Try to open Buy order on condition and !flag Buy_opened
Zone2: Try to open Sell order on condition and !flag Sell_opened
To New algo. and it work ok now.
If (PositionsTotal() > 0) return
Clear Buy and Sell open flag
If found that is buy position then set Buy_opened flag
Else If found that is sell position then set Sell_opened
Zone1: Try to open Buy order on condition and !flag Buy_opened
Zone2: Try to open Sell order on condition and !flag Sell_opened