OrdersTotal help

Ask general questions about the software
Message
Author
wennington
Posts: 2
Joined: Tue May 27, 2014 3:46 am

OrdersTotal help

#1 Postby wennington » Mon Oct 13, 2014 3:58 am

Hi,

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

FX Helper
Posts: 1479
Joined: Mon Apr 01, 2013 3:55 am

Re: OrdersTotal help

#2 Postby FX Helper » Tue Oct 14, 2014 9:18 am

Hello,

Do you use two the same strategies at the same time? So they both doing the same actions?

Or these strategies are different? For example, first strategy opens orders and second - closes them.

wennington
Posts: 2
Joined: Tue May 27, 2014 3:46 am

Re: OrdersTotal help

#3 Postby wennington » Tue Oct 14, 2014 12:35 pm

I replied in email, please check it.
Thank you!


Return to “General Questions about FT”

Who is online

Users browsing this forum: No registered users and 23 guests