Download MetaTrader 5
To add comments, please log in or register
1000 developers are involved in Freelance service activity. Sign up!
gotcha7
36
gotcha7 2009.08.24 10:51 

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
1395
JC 2009.08.24 11:19  
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 2009.08.24 12:00  

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
1574
cloudbreaker 2009.08.24 17:13  

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
5147
Stephen Njuki 2010.03.19 21:22  
Hey man your answers are always on point. They just keep getting me back on track. Thanks a bunch.
ron
3
ron 2014.05.05 04:49  
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
13641
whroeder1 2014.05.05 11:36  
manuel_campelo
45
manuel_campelo 2015.04.30 10:59  

 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
13641
whroeder1 2015.04.30 14:13  
  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 2015.05.01 08:55  
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