Discussion of article "Step-by-Step Guide to Writing an Expert Advisor in MQL5 for Beginners" - page 30

 
timmytrade #:

Tester - "Unsupported filling mode"

Tried on 3 different brokers. Whats the problem?

Try to replace SYMBOL_FILLING_FOK with SYMBOL_FILLING_IOC.

Regards, Vladimir.

 
Hi Samual, your article is great. And the technique of using indicator moving average and ADX is great because I tested it with EUR/US H2 currency pair on 2010.01.01 -2010.07.01 and 2017.01.01-2017.07.01. It's great. It's better than using indicator Hummer Hanging Man + Stochastics. And it's better than ThreeEMA Indicator. Thanks. Now I'm working on your code.
 
mirac baver ozturk #:

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.

This code works already.
 

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.




   

 
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.

 
Alain Verleyen #:

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.

       

 
Niwath Jeamphue #:

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

MetaTrader 5 features hedging position accounting system
MetaTrader 5 features hedging position accounting system
  • 2016.03.21
  • www.mql5.com
In order to expand possibilities of retail Forex traders, we have added the second accounting system — hedging. Now, it is possible to have multiple positions per symbol, including oppositely directed ones. This paves the way to implementing trading strategies based on the so-called "locking" — if the price moves against a trader, they can open a position in the opposite direction.
 

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.

Files:
 
MrBrooklin #:

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