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

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
Does anyone know if I can use this EA for mini-indexes or mini-dollars?
Hi guys, good morning.
I'm in the"Strategy Tester" with this file from the end of the Guide and it shows the following error:
*the error has already been discussed here in this article, but no written solution has worked for me and I need your help.
The file is at the end of the Guide.
How can I solve this problem?
I also still have this error having made both suggested corrections:
ZeroMemory(mrequest);
and also
if(Buy_opened || Sell_opened)
Please can someone help with the error 4756? It just seems unable to place a Buy Order.
Check if you used the SymbolInfoTick function and wrote this part of the code:
Since PositionSelect selects the first position for _Symbol, if the EA opens a buy position, the Sell_opened variable will always be false while the buy position is open, causing multiple sell positions to be realised whenever there is a sell signal.
To correct this and know if there are buy and sell positions open simultaneously, the following logic can be used:
Hello everyone, good morning.
I'm in the"Strategy Tester" with this file from the end of the Guide and it shows the following error:
*the error has already been discussed here in this article, but no written solution has worked for me and I need your help.
The file is at the end of the Guide.
How can I solve this problem?
Check the sale price you are requesting, to do this use breakpoint to debug the mrequest.price, mrequest.sl and mrequest.tp variables.
Try changing
to:
Some papers have minimum stop loss rules, read more here: https://www.mql5.com/pt/forum/319474
Hello,
Thank you very much for the article Samuel, you are a crack!
It was a bit difficult to get it to work with my broker because the article is in "net" mode and I had to look for information to put it in "hedging" mode. The first problem I encountered was with the mrequest.type_filling .
For the XM broker, the one that works is:
If you don't know which one your MT5 allows, my recommendation is to use the TypeFilling() functionin a Print(TypeFilling()) or a Comment( TypeFilling()) and it returns the type; if it tells you it is 1 (ORDER_FILLING_FOK) or 2 (ORDER_FILLING_IOC) you know which one you have to put(https://www.mql5.com/docs/constants/tradingconstants/orderproperties#enum_order_type_filling) becauseORDER_FILLING_FOK (1) doesn't work for me with this broker.
Once that is fixed, the problem is that PositionSelect opens a lot of positions. Although Samuel doesn't say it in his strategy, I understand that the objective is to open a single buy or sell position (whichever comes first) with the established criteria (the 4 boolean steps) and that until this position is closed, we can't open another one.
What I have done is to change this code ...
For this one...
Note: Just after comes the line...
This way it worked fine for me. I hope you find it useful.
Best regards.
I also still have this error having made both suggested corrections:
ZeroMemory(mrequest);
and also
if(Buy_opened || Sell_opened)
Please can someone help with the error 4756? It just seems unable to place a Buy Order.
Maybe the Filling Type of your Broker is ORDER_FILLING_IOC , you can try to edit the code from:
mrequest.type_filling = ORDER_FILLING_FOK;
To:
mrequest.type_filling = ORDER_FILLING_IOC;
I had the same problem and now I solved it successfully