| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Order tracking https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=84 |
Page 1 of 2 |
| Author: | matrixebiz [ Thu Nov 24, 2011 4:51 pm ] |
| Post subject: | Order tracking |
Hello All, just wondering what your techniques are for selecting specific orders on the same pair that have multiple orders currently open without using MagicNumbers or Comments. I was thinking of using something like OrderOpenTime() but haven't checked this Return to see what type of value it spits out and how to implement this type of checking with EA's that use the Recovery System. All options welcome Thanks |
|
| Author: | gaheitman [ Thu Nov 24, 2011 5:21 pm ] |
| Post subject: | Re: Order tracking |
Do you need to get just the first or the last order, or will you need to find one in between? For the first or the last, you can just iterate through the orders list forwards or backwards (respectively) and just take the first match. Doesn't OrderOpenTime() change after the order is actually filled, if you start with a pending order? I seem to remember running across that at some point. Not sure if it matters anyway, but it might change the order if you suspected the order was on when you placed them. And if I am remembering wrong, it really doesn't matter. You could also keep track of the orders in an array as you place them. If you use a multi-dimensional array you can keep track of additional data you want for each order (as long as you map it to integers). George
|
|
| Author: | matrixebiz [ Thu Nov 24, 2011 5:38 pm ] |
| Post subject: | Re: Order tracking |
No, I will actually need to check every open order for the pair as I have a CloseAll function that calculates the profit of all the orders and closes them when a total profit is hit. Yes, you are correct but I'm not using pending orders so this should not affect me This sounds like a viable option but I'm not advanced enough in my coding abilities do do something like this unless you feel like elaborating on this with examples Thank you |
|
| Author: | gaheitman [ Thu Nov 24, 2011 6:17 pm ] |
| Post subject: | Re: Order tracking |
If you are just trying to close all the open orders when you hit a threshold of profit, something like this should work: Code: Select all This isn't finished code, just a quick example of the looping you would need. George
|
|
| Author: | matrixebiz [ Thu Nov 24, 2011 6:36 pm ] |
| Post subject: | Re: Order tracking |
Ok, that seems easy enough but it's an older EA of mine so I'll have to scan though it to see if that is all I was trying to do with the multiple orders. It uses a Recovery system in it as well, so not sure if that was also the reason I was using MagicNumbers to also keep track of those orders also. I'll get back to you on that. Thank you for the code |
|
| Author: | matrixebiz [ Thu Nov 24, 2011 6:49 pm ] |
| Post subject: | Re: Order tracking |
Hi, looks like I was using the extra magic numbers to find out if the first order was in DD so many pips hence needing a recovery order then if profit was still not hit, needed to check if the second order is now also in DD by so many pips to place another recovery order, etc. Code: Select all |
|
| Author: | gaheitman [ Thu Nov 24, 2011 7:08 pm ] |
| Post subject: | Re: Order tracking |
The code to go through them all and close them would still be appropriate. I also finally took a look into MPTM, and it has the ability to monitor a basket of trades (here it would be a basket of the same currency) and close them all if they meet a predefined profit. Certainly worth a look. http://www.stevehopwoodforex.com/phpBB3 ... ?f=21&t=64
|
|
| Author: | matrixebiz [ Thu Nov 24, 2011 7:23 pm ] |
| Post subject: | Re: Order tracking |
... but the problem here is that if you see in the recovery code, I'm not actually looking for it to check the profit and close them all at this moment in time, I need it to check specific orders to see if an order is at a certain amount of DrawDown so I can tell the EA to open another order. So basically what I need for example is for the EA to check on lets say the third order I've opened and see how many pips it is in the negative and if it is -200pips then the EA will determine if I will open another order. This is why I was using MagicNumber + 2 on the third order opened so I could check on that order specifically. Sorry if this is getting confusing. |
|
| Author: | gaheitman [ Thu Nov 24, 2011 7:49 pm ] |
| Post subject: | Re: Order tracking |
I'm reading the code out of context, but I thought that this was a test to see if we need to enter a new trade. For example, in this test: Code: Select all Another way of looking at the test is to just examine the first trade. If it goes against us ReEntryLinePips, enter a trade. If it then goes against us ReEntryLinePips*2, enter a trade. You want to stop when the number of open trades exceeds the max number of recovery trades you are willing to enter + 1. Your code just has to keep track of the first ticket number and re-select it after you enter a trade. Or, if you are just trading one currency, one direction at a time, you can just select the first trade in the list with OrderSelect(0, SELECT_BY_POS)
|
|
| Author: | matrixebiz [ Thu Nov 24, 2011 8:05 pm ] |
| Post subject: | Re: Order tracking |
I wrote the code so you are correct in what I'm trying to do here ... Ok, now to the solution of getting rid of MagicNumber tracking |
|
| All times are UTC | Page 1 of 2 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|