Help me understand why Order failed to open ?

 

Hi,

Under my EA the order failed to open saying in log "Invalid S/L or T/P" while SL and TP are set to NULL, it happened in very volatile market and spreads were widened at that moment.

1 12:01:09.942 '11111': order sell stop 1.20 GBPUSDmicro opening at 1.32476 sl: 0.00000 tp: 0.00000 failed [Invalid S/L or T/P]

Thank you.

 

So fix your code. The problem comes from the price.

 
Do you really expect an answer?
We can't see your broken code.
There are no mind readers here and our crystal balls are cracked.
 
whroeder1:
Do you really expect an answer?
We can't see your broken code.
There are no mind readers here and our crystal balls are cracked.

How do you know his code is broken? He posted his log entry.

 
nicholishen:

How do you know his code is broken? He posted his log entry.

If you get an "invalid SL/TP" (error 130) that's because the code doesn't manage it correctly.

 
Alain Verleyen:

If you get an "invalid SL/TP" (error 130) that's because the code doesn't manage it correctly.

His sl and tp are both null...
 

It's the only error among thousands successful orders since I started with my EA 2 years ago, I gave you the exact circumstance which is widen spread at very volatile market

I didn't estimated that the code is broken this is why I didn't post it, I see the contradiction in log entry "Invalid S/L or T/P" while SL and TP are set to NULL.

  TicketSell2 = OrderSend(Symbol(), OP_SELLSTOP, Lot2, OpenSellPrice1, UseSlippage, NULL, NULL, "Sell1Case", MagicN, 0, clrGreen);        
 
nicholishen:
His sl and tp are both null...

That's why I said the error is in the price.

 
Toufik:

It's the only error among thousands successful orders since I started with my EA 2 years ago, I gave you the exact circumstance which is widen spread at very volatile market

I didn't estimated that the code is broken this is why I didn't post it, I see the contradiction in log entry "Invalid S/L or T/P" while SL and TP are set to NULL.

Your code is "broken", in the sense it doesn't manage correctly all circumstances. Error 130 is also about open price.

Firstly, but it's a detail, a TP/SL should set to 0 if you don't want to use one. Not NULL.

Secondly, you need to check your open price against market price, is it done ? Is it done correctly ? I can say you it's not. Nothing more from what you posted.

 

I agree with @Alain Verleyen, it's the price, not the SL or TP.

Note: Pending orders SellStop cannot be placed closer to the market price Bid than at the minimum distance StopLevel.
 
Alain Verleyen:

Your code is "broken", in the sense it doesn't manage correctly all circumstances. Error 130 is also about open price.

Firstly, but it's a detail, a TP/SL should set to 0 if you don't want to use one. Not NULL.

Secondly, you need to check your open price against market price, is it done ? Is it done correctly ? I can say you it's not. Nothing more from what you posted.

Based on log error message, I excluded that open price may be the source of the error, now probably it's the reason because I didn't check it in widen spread circumstance.

Thank you. 

Reason: