B-1 | 0.12
B-2 | 0.33
B-2 | 0.10
B-1 | 0.03
B-1 | 0.22
B-1 | 0.15
If a certain condition is met, for example Close[0] > EMA(9)[0] I want to ExitLong on all the B-1**** for example.
I got as far as this code:
OnBarUpdate() ....
if (condition) {
foreach (Order order in Account.Orders){
Print("\n\nORDER NAME: " + order.Name);
if (order.Name.Contains("B-1") ) {
ExitLong(order.Name);
}
}
.......
I only get over and over:
ORDER NAME: B-1 | 0.12
Just as I finished typing this I had a hunch and went to look into my accounts tab and I see that there is a rejected order in there called B-1 | 0.12! So obviously this is what I am looping through but for backtesting purposes, I'd need to be able to get the "open orders on each bar update rather than realtime" hope this is making sense.
So, the question is with the Lifetime license: How can I program my strategy to ExitLong("B-1*") on each tick or bar update but leave open all B-2*, B-3*, A^, etc, etc ...if you know what I mean? I need to access the strategy order list and NOT the "current" orders.
Any help on this would be extremely appreciated and if you could provide a complete working example I'd be forever grateful!
Comment