I created a ForexTester 2 strategy in C++.
It works well, open positions and write the pieces of buys, sells, etc into labels.
When I close a position manually I can see the change of the pieces in the label.
So it works right.
My problem starts when I use 2 strategies and the otherone closes my positions.
In the Forex Tester 2's Open positions window I see 0 position (other program closed all) but my strategy sees the closed orders like opened.
So it can recognize the close of the position when I close it manually, but can't when an other program closes it.
Is there any function I can use to refresh the orderlist?
Or dou you have any ideas?
My position counter codepart:
Code: Select all
int ordertype;
int b = 0;
int s = 0;
int b_p = 0;
int s_p = 0;
for(int i = 0; i < OrdersTotal(); i++){
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){
if(strcmp(OrderSymbol(), Symbol()) == 0 && OrderMagicNumber() == magicNumber){
ordertype = OrderType();
switch(ordertype){
case tp_Buy : b++;break;
case tp_Sell : s++;break;
case tp_BuyLimit : b_p++;break;
case tp_SellLimit : s_p++;break;
case tp_BuyStop : b_p++;break;
case tp_SellStop : s_p++;break;
}
}
}
}
Thnak you for your answer
BR
Laszlo