is the OrderSend failing? What are Function return values ? How do I use them ? - MQL4 forum
add to that . . . did the OrderSelect() work ? did the OrderModify() work ? you are ignorant of this information . . . enlighten yourself with some information and you will have a much better chance of fixing your issue . . . despite the saying, ignorance is not bliss.
i added
int ErrorCode = GetLastError (); string ErrDesc = ErrorDescription (ErrorCode); string ErrAlert = StringConcatenate (“argMode – error: “, ErrorCode, “: “, ErrDesc); Alert (ErrAlert); string ErrLog = StringConcatenate (“Ask: “, MarketInfo (argSymbol, MODE_ASK), “Bid: “, MarketInfo(argSymbol, MODE_BID)); Print(ErrLog);after every OrderSend or OrderModify, but no error was found, and no trade was open though...
i added after every OrderSend or OrderModify, but no error was found, and no trade was open though...
No you didn't . . . if you did your code would not compile.
If OrderSend() is called it does one of two things, it sends the order or causes an error . . . if neither of those is happening then it is not being called.
Have you actually allowed your EA to trade live ? do you have a smiley face in the top right hand corner of your chart ?
In MT4 . . .
In the EA settings . . .
On MT4 menu bar . . .
yes the EA is allowed to trade live, and i click on the button Expert Advisor.
There is no error displayed, but when the fast MA crosses the Slow MA above, no open trade is done. Is there any logical error in it ?
int ErrorCode = GetLastError (); string ErrDesc = (ErrorCode); string ErrAlert = StringConcatenate (“argMode – error: “, ErrorCode, “: “, ErrDesc); Alert (ErrAlert); string ErrLog = StringConcatenate (“Ask: “, MarketInfo (argSymbol, MODE_ASK), “Bid: “, MarketInfo(argSymbol, MODE_BID)); Print(ErrLog);indeed, but it's not responsible for my problem. i cut it in my first post because the EA was too long it said.
The way you are using functions doesn't make a lot of sense . . . if a function is designed to returns a value then you should use that return value . . .
TradeAllowed = fTradeAllowed (iTimeDebut, iTimeFin); bool fTradeAllowed (int iTimeDebut, int iTimeFin) { iTimeSeconds = Hour()*3600 + Minute()*60 + Seconds(); // Conversion de l'heure actuelle en secondes ; if(iTimeSeconds >= iTimeDebut && iTimeSeconds < iTimeFin) // Vérification si l'heure est dans la plage horaire du filtre horaire return(true); else return(false); }
. . . you can also use local variables in the function instead of globally declared variables.
and i put indeed, but it's not responsible for my problem. i cut it in my first post because the EA was too long it said.
Do something like this . . .
iBuyTicket = OrderSend (Symbol(), OP_BUY, fLots(dPourcentageRisque, iStop), MarketInfo(Symbol(), MODE_ASK), fSlippage(Symbol(), iSlippage), 0, 0, 0, iMagic, 0, Green); if(iBuyTicket == -1) { Print("Order Send failed, error # ", GetLastError() ); } else { if(OrderSelect(iBuyTicket, SELECT_BY_POS)) if(!OrderModify(OrderTicket(), OrderOpenPrice(), dBuyStop, 0, 0, 0)) Print("Order Modify failed, error # ", GetLastError() ); }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I coded this EA but it never opened any trade, someone knows why ?