| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Deleting pending orders https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=2605 |
Page 1 of 2 |
| Author: | traderuk [ Mon Jun 24, 2013 5:02 pm ] |
| Post subject: | Deleting pending orders |
Hi, Can you help please I'm getting some pending orders not deleting (usually when a trade is initiated on opposite side)? On each bar I'm trying to close all pending orders... Code: Select all Code: Select all Also not sure how to call the function when it is removed, from what I understand it would simply be ClosePending(); ? I did try counting the pending orders to determine the magic number... Code: Select all Code: Select all Stefan |
|
| Author: | traderuk [ Mon Jun 24, 2013 5:09 pm ] |
| Post subject: | Re: Deleting pending orders |
Think I just realized what I did... checking only for OP_BUYSTOP. Doh! Although I'd have thought the orders should still have closed while not referencing the count and just doing ClosePending direct with the OrderDelete. If anyone can help with the other questions or if there's better ways to do what i'm trying to do in any of the code I'd be very grateful. Would rather do this properly to some uber standard then just mish mash |
|
| Author: | traderuk [ Mon Jun 24, 2013 5:54 pm ] |
| Post subject: | Re: Deleting pending orders |
Simplified in to one block of code. Found that I need to count down when deleting pendings but some trades are still being missed. I tried splitting the order types as figured it might be returning 1 before the next ticket was found. I'm stuck. Code: Select all |
|
| Author: | phil_trade [ Mon Jun 24, 2013 6:16 pm ] |
| Post subject: | Re: Deleting pending orders |
Hi Why do you pass MagicNumber as parameter without using it ? Why do you call a Return(1) Inside the For loop ? Why don't you also select OP_SELLLIMIT and BUY_LIMIT ? Philippe |
|
| Author: | traderuk [ Mon Jun 24, 2013 6:23 pm ] |
| Post subject: | Re: Deleting pending orders |
Hi Philippe - Have fixed the MagicNumber... I didn't know how to create the function without passing, realized now that it's just void ClosePendings(). - I thought the return(1) would set the value of trade to 1, making the loop run through. I'm not really sure if that's what return() does or if I'm doing it the correct way at all? - Am only working with buy/sell stops at the moment. Thanks for your time and help. Stefan |
|
| Author: | phil_trade [ Mon Jun 24, 2013 6:45 pm ] |
| Post subject: | Re: Deleting pending orders |
A return operator terminates the current function execution and returns the control to the calling program so your return stop the For loop ! you don't need it ! |
|
| Author: | dietcoke [ Mon Jun 24, 2013 7:45 pm ] |
| Post subject: | Re: Deleting pending orders |
Are you wanting to close all your pendings at the start of each bar? |
|
| Author: | traderuk [ Tue Jun 25, 2013 7:12 am ] |
| Post subject: | Re: Deleting pending orders |
Yes please. I'm learning to code but I can't find any useful enough documentation on how to do this. |
|
| Author: | traderuk [ Tue Jun 25, 2013 9:23 am ] |
| Post subject: | Re: Deleting pending orders |
I think the issue is with ticket numbers and how they're incremented as a trade triggers from buy/sell stop to buy/sell. Attached is the code i'm working on. There's not much of it and it's tidy. If you could have a quick look and tell me if I'm doing anything a non-standard way that would be very much appreciated. I feel like I'm starting to bodge it together and would rather know if it's wrong before it ends up a complete bodge - In particular the stoploss and trailingstop of -1 to activate the auto stop movement - ticket counting to be able to properly closing pending orders - current buy/sell trades if they match criteria e.g if(Close[1]<Open[1]) CloseLongs(MagicNumber);not closing properly, probably ticket counting again. Thanks lots! |
|
| Author: | dietcoke [ Tue Jun 25, 2013 11:17 am ] |
| Post subject: | Re: Deleting pending orders |
If you know the time at which you want to close a pending order, ie at the end of a particular bar or at a certain time of day, the best way to do this is to set the expiry time of the order when you open it. So, lets say it's 12:30 and you want to open a pending to be cancelled at the end of the current H1 bar(ie. 13:00), you can use the code below to calculate the expiration time of your order. You then include the expiration ou have calculated in your ordersend call. Code: Select all you can just set your orders to expire at a particular time of day. Code: Select all |
|
| All times are UTC | Page 1 of 2 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|