Gooly, I don't see an error in the code. Additionally it works perfect when placing a forex order and the first CFD order. The error #130 only occurs when sending the second CFD order. I don't find anything in my code what could cause that error. As you can see, I place the second order immediately after the first without changing the SL. Therefore I am sure it must be some MT4-CFD-problem. Forex orders work without problems.
Very strange, isn't it?
Ticket1 = OrderSend(NULL,Order_Type,lotSize,Entry,3,SL,TP1,"",0,0,CLR_NONE); if (TwoOrders) Ticket2 = OrderSend(NULL,Order_Type,lotSize,Entry,3,SL,TP2,"",0,0,CLR_NONE); if(Ticket1 < 0) { Alert("OrderSend #1 failed with error #",GetLastError());
- If the first send fails, you've lost GetLastError because of the second call. Process errors immediately. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
- The only difference between the two is TP1 and TP2 and you didn't bother to show them. Print the values - find out why.
William, as usual, you are genius! TP2 was the problem. In a calculation I used a minus instead of a plus. That caused all problems. But how can it be that a wrong TP cause an invalid stop error?
Thank you so much!
William, as usual, you are genius! TP2 was the problem. In a calculation I used a minus instead of a plus. That caused all problems. But how can it be that a wrong TP cause an invalid stop error?
Thank you so much!
You misinterpreted error 130, it's not about stoploss, but about stops : "Invalid stops". TP is a stop order.
TP is a stop order.
( A t/p is more usually regarded as a limit order. If you sell at 1.00 with a s/l at 1.1 and a t/p at 0.9, then it's equivalent to a buy-stop at 1.1 and a buy-limit at 0.9. In a platform such as Ninjatrader, which doesn't have an MT4-style s/l or t/p as an "attribute" of a position, you would create pending stop and limit orders and bind them together in an OCO group. )
You are right, I should have said : TP is a stop value (like SL and so subject to error 130). It's MT4 terminology.
- 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 coders,
I always receive an error #130 when I place two pending CFD orders. Placing two forex orders is no problem. But when I want to trade oil, gold, dax, s&p (anything where MODE_PROFITCALCMODE = 1) only one order is sent and for the second order I receive error #130. But WHY?? I don't change the Stoploss before sending the second order. So how can it be that the Stop is ok when sending the first order but not with the second?