Isn't this the case?
The function returns the last occurred error, then the value of special last_error variable where the last error code is stored will be zeroized. So, the next call for GetLastError() will return 0.
Try to have a look into the log in metatrader, since you call the function twice, so I think the error will be saved through your Print function in the MetaTrader log but not in your own file.
Jan
The function returns the last occurred error, then the value of special last_error variable where the last error code is stored will be zeroized. So, the next call for GetLastError() will return 0.
Try to have a look into the log in metatrader, since you call the function twice, so I think the error will be saved through your Print function in the MetaTrader log but not in your own file.
Jan
Check your parameters for the OrderSend.
Use GetLastError like this:
{
int error = GetLastError();
Print("OrderSend failed with error #", error );
write_time("OrderSend failed with error #"+error );
return(0);
}
Great help there. Thanks both of you.
The error code is 134, meaning "Not enough money."
I'm trading 0.2 lot with 1k account. I tried with 0.01 lot and got the same error code. I don't understand that issue...
The error code is 134, meaning "Not enough money."
I'm trading 0.2 lot with 1k account. I tried with 0.01 lot and got the same error code. I don't understand that issue...
mjollnir:
Great help there. Thanks both of you.
The error code is 134, meaning "Not enough money."
I'm trading 0.2 lot with 1k account. I tried with 0.01 lot and got the same error code. I don't understand that issue...
And I don't have any open position.
Great help there. Thanks both of you.
The error code is 134, meaning "Not enough money."
I'm trading 0.2 lot with 1k account. I tried with 0.01 lot and got the same error code. I don't understand that issue...
Thanks! Silly search and replace error :)
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Everytime the code is executed, ticket value is -1, meaning there has been a problem but GetLastError() returns 0, meaning everything is OK.
The order is not passed.
This happens on backtesting, and probably real trading too.
write_time() is my own function to log data into a file.
Any clue?