sorry i forget to mention, the loop that should be changed is the loop in the FilterOrders function
Quote:
void FilterOrders(int alType)
{
for(int i=OrdersTotal()-1;i>=0;i--)
|
it's different when handling order.
let me show you:
assume you have 4 opened order named OrderA, OrderB, OrderC, OrderD.
if you use for(int i=0;i<OrdersTotal();i++), then the sequence would be
- in the order pool, index OrderA = 0, index Order B = 1,...index OrderD = 4
- at first loop, i = 0, OrderA will be closed
- now there are 3 remained opened order, ie : OrderB, OrderC, OrderD
- in the order pool, OrderB will be assigned index 0,
OrderC will be assigned index 1, and OrderD will be assigned index 2
- at second loop,
i = 1, OrderC will be closed!! Not OrderB as you expected
- now there are 2 remained opened order, ie: OrderB, OrderD
- OrderB will be assigned index 0, OrderD will be assigned index 1
- at third loop, i = 2, there is no opened order that has index 2, so nothing will be closed!!