Some months ago, George (TIG) knocked out a quick script for me to implement OCO (Order Cancels Order) behavior. I place two breakout trades around the current price, and when one fills, the other should be canceled. The script stays in a start() loop until one of the orders fills, then it cancles the other and exits.
The script behavior has always been a bit flaky. Usually it cancels the orders correctly, but sometimes it doesn't, and neither George nor I could figure out why.
Last night I had something really bizarre happen that I can only think was the script. I had several OCO orders open, and one of them canceled BOTH orders before either had been hit. (I checked with my broker and they said the cancel request came from the same IP as the original order.) *I* sure didn't cancel them manually. We had a raging thunderstorm at just about the time the orders were canceled, but I can't see how power or net glitches could cause the script to think it should cancel.
And, of course, the trade would have been a winner. This stuff never happens on losing trades...
Can anyone figure out why this thing misbehaves? Or does someone have a good reliable OCO script?
OCO script has inconsistent behavior
-
garyfritz
OCO script has inconsistent behavior
You do not have the required permissions to view the files attached to this post.
-
dietcoke
- Trader
- Posts: 162
- Joined: Tue Nov 15, 2011 9:59 pm
Re: OCO script has inconsistent behavior
Did they cancel together or with a big gap? and how long after they were opened did it happen?garyfritz wrote:Some months ago, George (TIG) knocked out a quick script for me to implement OCO (Order Cancels Order) behavior. I place two breakout trades around the current price, and when one fills, the other should be canceled. The script stays in a start() loop until one of the orders fills, then it cancles the other and exits.
The script behavior has always been a bit flaky. Usually it cancels the orders correctly, but sometimes it doesn't, and neither George nor I could figure out why.
Last night I had something really bizarre happen that I can only think was the script. I had several OCO orders open, and one of them canceled BOTH orders before either had been hit. (I checked with my criminal and they said the cancel request came from the same IP as the original order.) *I* sure didn't cancel them manually. We had a raging thunderstorm at just about the time the orders were canceled, but I can't see how power or net glitches could cause the script to think it should cancel.
And, of course, the trade would have been a winner. This stuff never happens on losing trades...
Can anyone figure out why this thing misbehaves? Or does someone have a good reliable OCO script?
I would consider using matts OR library for the orders and leave the error handling to that.
The only ways I can see both orders being cancelled are:
1) if the Alt+X escape keys are pressed.
2) If the Orderselect() function fails to read the pending ticket multiple times and hits the error limit
-
garyfritz
Re: OCO script has inconsistent behavior
I placed the orders at about 01:00 GMT+3, and they were canceled at 07:18 and 07:19. Close together, but not exactly at the same time. Maybe one was 07:18:59 and the other was 07:19:00, but... I don't THINK I hit Alt-X on it! I don't remember even opening that Empty4 last night.
Maybe the storm caused a net outage that caused the Orderselect() to fail? But I've had outages plenty of times and this has never happened before. I've successfully executed over 50 orders with this script.
No inspiration of why it sometimes doesn't cancel the "didn't get hit" order?
Maybe the storm caused a net outage that caused the Orderselect() to fail? But I've had outages plenty of times and this has never happened before. I've successfully executed over 50 orders with this script.
No inspiration of why it sometimes doesn't cancel the "didn't get hit" order?
-
chimera
- Trader
- Posts: 13
- Joined: Sun Dec 11, 2011 12:39 pm
Re: somewhat related
Hey
Is there any way that i can bother you for OCO related code. Have this script made in to a reliable EA, executing on open of new bar if no trades are found.
Distance from price, MagicNumber, TP, SL as the extern parameters.
Chi
Is there any way that i can bother you for OCO related code. Have this script made in to a reliable EA, executing on open of new bar if no trades are found.
Distance from price, MagicNumber, TP, SL as the extern parameters.
Chi
Advertising space for sale
-
garyfritz
Re: OCO script has inconsistent behavior
I'm not in a position to convert/upgrade this thing right now. Maybe somebody else will volunteer to convert it to the ReliableOrder library calls but right now I just can't.
