Discussion of article "Step-by-Step Guide to Writing an Expert Advisor in MQL5 for Beginners" - page 17
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
I downloaded the file and debugged the code, and it showed this warning could someone help me with this ?
return value of'OrderSend' should be checked
Hello, I'm a newbie and I'm also testing the Robot
Try this:
// OrderSend(mrequest,mresult);
bool res=OrderSend(mrequest,mresult);
// get the result code
if(res && (mresult.retcode==10009 || mresult.retcode==10008)) //Request is completed or order placed
{
Alert("A Buy order has been successfully placed with Ticket#:",mresult.order,"!!");
}
else
{
Alert("The Buy order request could not be completed -error:",GetLastError());
ResetLastError();
return;
}
If I'm wrong, please correct me!
Research source: https://www.mql5.com/en/forum/23663
When I'm debugging, I always get an error when I send the order. I thought it was my code, but even when I test the mql5 file for downloading it also gives me an error.
When I'm debugging, I always get an error when I send the order. I thought it was my code, but even when I test the mql5 file for downloading it also gives me an error.
I think the example is in currencies, so the lot variable that is 0.1 is not suitable for your test, try changing it like this (changing the mrequest.volume variable):
double minSymbolLot = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
mrequest.action = TRADE_ACTION_DEAL; // immediate order execution
mrequest.price = NormalizeDouble(latest_price.ask,_Digits); // latest ask price
mrequest.sl = NormaliseDouble(latest_price.ask - STP*_Point,_Digits); // Stop Loss
mrequest.tp = NormaliseDouble(latest_price.ask + TKP*_Point,_Digits); // Take Profit
mrequest.symbol = _Symbol; // currency pair
mrequest.volume = minSymbolLot; // number of lots to trade
mrequest.magic = EA_Magic; // Order Magic Number
mrequest.type = ORDER_TYPE_BUY; // Buy Order
mrequest.type_filling = ORDER_FILLING_FOK; // Order execution type
mrequest.deviation=100;
Does anyone know if I can use this EA for mini-indexes or mini-dollars?
Have you understood the strategy? Are you aware of the risks? Have you analysed the SL and TP levels? Do you know the technical indicators used? Do you know how to parameterise them? Do you know how to customise the variables for each asset (WIN and WDO)?
The code itself has been developed for any asset and you can identify this through the "_Symbol" and for any chart time "_Period".
Now it's important that you know what you're doing when you run the EA. If you choose to do so, I suggest that you only work on demo accounts until you have mastered the tool and have a better understanding of the stock market.
[ ]'s
Guys,
This is a simple quick modified code if you have an error with multiple orders opening at the same time.
Replace this code : from line 167 -177
with this:
Thanks @Samuel Olowoyo
Please advise how to solve the problem. The Expert Advisor opens several positions in a row to buy, the same for selling.
The Expert Advisor does not see that there are already open Buy and Sell positions and opens new ones, despite the fact that there is a check in the code.
for already open positions. The check does not work for some reason.
Since there is no help from the troll-moderators here, I will copy the answer from the English forum:
Guys, this is a simple quick modifiable code, if you have an error with several orders opening at the same time. Replace this code: from line 167 -177
With this:
Since I can't get any help from the troll-moderators here, I'll copy the answer from the English forum:
Guys, this is a simple quick modifiable code if you have an error with multiple orders opening at the same time. Replace this code: from line 167 -177
With this: