Although GetLastError() has this innocent looking name starting with "Get" it has side effects!
It will reset the error number, the next call will return 0. You can only call it once. do it like:
err = GetLastError(); if (err == 146){ ... } Print(err);
Thanks, i got it . i understand the Print(.... ) have bug. :( .
Thanks, i got it . i understand the Print(.... ) have bug. :( .
why :( ?
it is not the Print(), it is you calling GetLastError() a second time (inside the print), so it will always give 0 as error number and it won't show the real error that happened. Do it like in my example and you will see the correct error number.
Sorry for my replay, i didn't expect it, i just want to say this line have problem,(first time call GetLastError() function after the system reset the error code to "0")
Thanks
- As for the why it fails, you buy at the Ask, Open[] close[] are the Bid.
- You also must adjust TP, SL, and slippage for 5 digit brokers. Demo and live may be different. Also never any slippage on demo.
//++++ These are adjusted for 5 digit brokers. double pips2points, // slippage 3 pips 3=points 30=points pips2dbl; // Stoploss 15 pips 0.0015 0.00150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits == 5 || Digits == 3){ // Adjust for five (5) digit brokers. pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
in the Demo account it works, but in my live account, most times show me error. i don't know what's problem for this EA
Welcome any advice for this EA
Thanks
Error:
USDCAD,M1: Order Buy faild!ErrorCode:0 Close:1.0227 Stoploss:15 Open:1.0239 Stop:1.0224 Profit:1.0269
Source Code