Hi,
I have created an ea with an OrderModify to add a Stop Loss to an open order, but every time it is executed, I receive a 141 error (too many requests). I don't know why.
Can you help me, please?
Thank you
Only do it once . . . . don't keep trying to Modify the same order . . .
Hi RaptorUK,
But I'm trying to do a trailing stop in my ea, so I must modify the order every time it is needed. Anyway, the first modify already shows this error.
Thank you
Hi RaptorUK,
But I'm trying to do a trailing stop in my ea, so I must modify the order every time it is needed. Anyway, the first modify already shows this error.
This is part of the code:
<SNIP>
This is the first time OrderModify is used. Then, every tick, if the stop loss has to be moved, a new OrderModify (in a function executed later in the code) is executed.
Thank you
landmeister: This is the first time OrderModify is used. Then, every tick, if the stop loss has to be moved, a new OrderModify (in a function executed later in the code) is executed.
For large amounts of code, attach it
- Here is your code simplified.
Stop_Loss_b=Busqueda_Fractal(superior); tb=Lanzar_Operacion(OP_BUY,num_lotes,0,TP,compra); : if (OrderSelect(tb,SELECT_BY_TICKET)) { SL_b=OrderOpenPrice(); : OrderModify(tb,SL_b,Stop_Loss_b,0,0);
Where are you checking if the current values are equal/not equal to the new ones? - You would never write IF( (2+2) == 4) == true) would you? Then don't write IF( bool == true). IF(bool) and IF(!bool) is sufficient, simpler, and more readable.
This is part of the code:
<SNIP>
This is the first time OrderModify is used. Then, every tick, if the stop loss has to be moved, a new OrderModify (in a function executed later in the code) is executed.
Please use this to post code . . . it makes it easier to read.
This is part of the code:
This is the first time OrderModify is used. Then, every tick, if the stop loss has to be moved, a new OrderModify (in a function executed later in the code) is executed.
Read this for more info: What are Function return values ? How do I use them ?
Thank you for your replies.
Ok, I didn't know there was a button to insert the code. I will use it from now on.
As I already said, I check the values later on my code, and this is done every tick. I just post this piece of the code to show that the first time I modify the order, the error shows.
I know that GetLastError should be used only when OrderModify fails but still I don't see why I have error 141. If I use GetLastError as you said, should the error change?
Thank you again
Hi, I did the changes you told me:
1) I simplified the "if" statement.
2) I used GetLastError() only when OrderModify is not valid.
And still the same 141 error as soon as the stop loss is added.
I attach the simplified code.
Regards,
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I have created an ea with an OrderModify to add a Stop Loss to an open order, but every time it is executed, I receive a 141 error (too many requests). I don't know why.
Can you help me, please?
Thank you