Download MetaTrader 5

error 4108

To add comments, please log in or register
gotcha7
36
gotcha7  

hi, folks

I'm really impressed with the deep knowledge expressed in the forum

my qustion is about error 4108 that kills my trade.

i get the order ticket by orderslect and then issue the ordererdelete function

to kill a pending sellstop order. most of the times i get the 4108 error, now is this ea system

a proffesional tool or just a nice marketing gimic, for tyoing and hvaing fun. ??!!

thank you.

JC
1499
JC  
yoserian:

my qustion is about error 4108 that kills my trade.

i get the order ticket by orderslect and then issue the ordererdelete function

You can get error 4108 for a number of reasons, including an attempt to delete an order which you have already successfully deleted. For example, if you call OrderDelete() twice with the same ticket number, the second call will fail. In essence, error 4108 seems to mean "either the ticket number is simply not valid, or the order is not valid for the action you are trying to perform on it".


now is this ea system a proffesional tool or just a nice marketing gimic, for tyoing and hvaing fun. ??!!

Both.

Magnus Meseck
123
Magnus Meseck  

What about using the GetLastError() - Function. It gives you more information about the reason the error occured....

If you never used it befor have a look here:

https://docs.mql4.com/check/GetLastError

Good luck

EP

cloudbreaker
1577
cloudbreaker  

Post your code if you will.

However, I've seen this being caused by the loop you use to cycle through orders incrementing rather than decrementing.

It can cause the behaviour jjc mentions above.

Look for something like i++ to indicate that this is your problem. In that case you'll need to turn your loop around to start counting downwards using the following as your index -> (total number of orders -1) to 0 inclusive.


CB

Stephen Njuki
5205
Stephen Njuki  
Hey man your answers are always on point. They just keep getting me back on track. Thanks a bunch.
ron
3
ron  
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)
break;
if((OrderSymbol()==Symbol()) && (OrderOpenPrice() == priceEnter))

I added some additional filters in my EA to get rid of that. but what cloudbreaker said was spot on.. its your loop


whroeder1
15351
whroeder1  
manuel_campelo
45
manuel_campelo  

 I have the same Issue but I'm not doing any loop over open open trades. I have an array of orders to close and I send a ticcket to Close Function.

I Attach an image where you can see the code, the values of the variables involved and the terminal info of the trades after trying to close an order with error 4108.

As you can see (sorry for the picture) ticket, Price, Lots, etc were alright. Does anyone know what happened?


whroeder1
15351
whroeder1  
  1. You are calling OrderClose for a pending order. OrderClose closes open orders. OrderDelete deletes pending orders.
  2. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
manuel_campelo
45
manuel_campelo  
Thanks WHRoeder, you always state things clear. And thanks for the links (I didn't find gthen cause I was looking for error 4108).
To add comments, please log in or register