Discussion of article "Step-by-Step Guide to Writing an Expert Advisor in MQL5 for Beginners" - page 7
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
The EA is opening many positions both buy and sell.
best way to correct it is This:
if(Buy_Condition_1 && Buy_Condition_2)
{
if(Buy_Condition_3 && Buy_Condition_4)
{
// any opened Buy position?
if(Buy_opened || Sell_opened)
{
Alert("We already have a open Position!!!");
return; // Don't open a new Buy Position
}
---------------The same is applicable to the sell position-----------------------
The original code under opens multiple positions:
if(Buy_Condition_1 && Buy_Condition_2)
{
if(Buy_Condition_3 && Buy_Condition_4)
{
// any opened Buy position?
if(Buy_opened ) //Error, should be: if(Buy_opened || Sell_opened)
Alert("We already have a open Position!!!");
return; // Don't open a new Buy Position
}
Please edit your post and use the code button (Alt + S) when posting code.
It's a bug in the EA. Take a look at page 2 where the solution is.
Better approach: use https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade class.
I'v got 4756 error, I saw the solution in page 2, and I checked orginal code, there was ZeroMemory(mrequest); in line 218 itself. but I have still the error 4756.
Hi All,
Brand new to MQL5 (and FOREX for that matter) but, long time programmer. I opened the My_First_EA.mq5 file and compiled but, I'm not getting the Debug functions. If I open any of the example script files I do get the Debug option. Also received a warning return value of 'OrderSend' should be checked. What do I have to do to get Debug functionality?
Louis
Hi All,
Brand new to MQL5 (and FOREX for that matter) but, long time programmer. I opened the My_First_EA.mq5 file and compiled but, I'm not getting the Debug functions. If I open any of the example script files I do get the Debug option. Also received a warning return value of 'OrderSend' should be checked. What do I have to do to get Debug functionality?
Louis
Hi All,
Figured out my own issue. I created a new Project with the Expert Advisor Wizard and then just copied in the My_First_EA.mq5 file and I get debug functionality.
Louis
Hi All,
Figured out my own issue. I created a new Project with the Expert Advisor Wizard and then just copied in the My_First_EA.mq5 file and I get debug functionality.
Louis
I'v got 4756 error, I saw the solution in page 2, and I checked orginal code, there was ZeroMemory(mrequest); in line 218 itself. but I have still the error 4756.
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.
Hi,
Similarly, I have the error code 4756 when running testing and said " Sell order request could not be completed ".
Please inform how to solve this.
Thank