Possible bug in OrderSendReliable2Step?

 

Hi all, I think I may have found a wee bug with OrderSendReliable2Step. I'm hoping the author reads this forum and sees this post. It would appear that I'm using v3.1 (I have no idea if this is the latest or not). What happened was: my EA issued a sell stop order on AUDJPY to sell 0.23 lots at 81.809. I guess the current market was too close to 81.909 so OrderSendReliable2Step bumped that down to 81.767... no problem. As you can see by the logs below, it then placed that order for 81.767 successfully. But then when it was OrderModifyReliable's turn to set the stoploss and profit targets, it erroneously used the old entry price (81.809) and not the newer, modified one that OrderSendReliable created (81.767). Therefore OrderModify was unable to successfully modify the order to place the stoploss and profit target. Here are the log statements:


05:16:56 LibOrderReliable AUDJPY,H1: loaded successfully

05:16:56 LibOrderReliable AUDJPY,H1: OrderSendReliable2Step v3.1:
05:16:56 LibOrderReliable AUDJPY,H1: OrderSendReliable2Step v3.1: Doing OrderSendReliable, followed by OrderModifyReliable:
05:16:56 LibOrderReliable AUDJPY,H1: OrderSendReliable v3.1:
05:16:56 LibOrderReliable AUDJPY,H1: OrderSendReliable v3.1: • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •
05:16:56 LibOrderReliable AUDJPY,H1: OrderSendReliable v3.1: Attempted SELL STOP 0.23000000 lots @81.80900000 sl:0.00000000 tp:0.00000000
05:16:56 LibOrderReliable AUDJPY,H1: OrderSendReliable v3.1: Pending SellStop has ERR_INVALID_STOPS; new price = 81.767
05:16:56 LibOrderReliable AUDJPY,H1: OrderSendReliable v3.1: Result of attempt 1 of 10: Retryable error: 130 :: invalid stops

05:16:56 LibOrderReliable AUDJPY,H1: OrderSendReliable v3.1: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

05:16:58 LibOrderReliable AUDJPY,H1: open #156324501 sell stop 0.23 AUDJPY at 81.767 ok
05:16:58 LibOrderReliable AUDJPY,H1: OrderSendReliable v3.1: Ticket #156324501: Successful SELL STOP order placed, details follow.
05:16:58 LibOrderReliable AUDJPY,H1: #156324501 2010.11.08 10:17 sell stop 0.23 AUDJPY 81.767 0.000 0.000 81.826 0.00 0.00 0.00 AUDJPY73650015 73650015
05:16:58 LibOrderReliable AUDJPY,H1: OrderSendReliable v3.1: • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 05:16:58 LibOrderReliable AUDJPY,H1: OrderSendReliable v3.1:

05:16:58 LibOrderReliable AUDJPY,H1: OrderModifyReliable v3.1:
05:16:58 LibOrderReliable AUDJPY,H1: OrderModifyReliable v3.1: • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •
05:16:58 LibOrderReliable AUDJPY,H1: OrderModifyReliable v3.1: Attempted modify of #156324501 price:81.80900000 sl:81.90800000 tp:81.71000000
05:16:58 LibOrderReliable AUDJPY,H1: OrderModifyReliable v3.1: OrderModifyReliable, ERR_INVALID_STOPS, should not happen; stops already adjusted

05:16:58 LibOrderReliable AUDJPY,H1: OrderModifyReliable v3.1: Result of attempt 1 of 10: Retryable error: 130 :: invalid stops

05:16:58 LibOrderReliable AUDJPY,H1: OrderModifyReliable v3.1: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

05:17:06 LibOrderReliable AUDJPY,H1: OrderModifyReliable v3.1: OrderModifyReliable, ERR_INVALID_STOPS, should not happen; stops already adjusted
05:17:06 LibOrderReliable AUDJPY,H1: OrderModifyReliable v3.1: Result of attempt 2 of 10: Retryable error: 130 :: invalid stops
05:17:06 LibOrderReliable AUDJPY,H1: OrderModifyReliable v3.1: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

05:17:08 LibOrderReliable AUDJPY,H1: OrderModifyReliable v3.1: OrderModifyReliable, ERR_INVALID_STOPS, should not happen; stops already adjusted
05:17:08 LibOrderReliable AUDJPY,H1: OrderModifyReliable v3.1: Result of attempt 3 of 10: Retryable error: 130 :: invalid stops
05:17:08 LibOrderReliable AUDJPY,H1: OrderModifyReliable v3.1: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~


... it just continued for all 10 tries and failed each time.


Thanks!

Shawn

 
I don't think u are going to get an answer from the original author. Those libraries have various versions, with minor changes done by various users, floating around for years... I recommend u just post your own corrected version here. Personally, I don't share the usual recommendation to blindly use these libraries, as there are various other problems with them...
 

Agreed

open #156324501 sell stop 0.23 AUDJPY at 81.767 ok

Attempted modify of #156324501 price:81.80900000 sl:81.90800000 tp:81.71000000

The price filled <> price used in the modify.

Personally, I don't agree with the library premise, try to handle errors and retry. The hardest is the ERR_NO_RESULT (1) The order may or may not have opened.

I simply log the error and return from start on any error. On the next tick, ModifyStops() will set the TP/SL if the order did open. Otherwise Decide() will retry the open. No retry logic needed.

Likewise if the terminal restarts, ModifyStops() simply resumes its trailing functions. No persistent storage needed.

 

Thanks guys, I did get a reply form one of the original co-authors Derk Wehler! He pointed out I was using an older version and that this bug had indeed been fixed. He sent along the latest version to me. I've attached the files to this post.


So thanks guys, and thanks Derk!


Shawn

Files:
 
... and the other file.
Files:
 
Cool! Thanks for posting.
 
no prob Gordon!