MQL4 - automated forex trading   /  

Forum

Adding up the lots...

Back to topics list To post a new topic, please log in or register

avatar
21
Xlr8er 2010.08.04 18:32 

Hello is there anyone that knows the code of how to sum up all your trades and return the value of all your open orders position sizes and add them together....

for example if I had two open orders of 0.5 and 0.4 .... the EA would return that I have 0.9 in total positions ...

I would like it to return 3 values... one of the sells total, one of the buys total and then the complete total both buys and sells position sizes.

Thanks so much.

Multiple Null Bar Re-Count in Some Indicators

Multiple Null Bar Re-Count in Some Indicators

The article is concerned with the problem of re-counting of the indicator value in the MetaTrader 4 Client Terminal when the null bar changes. It outlines general idea of how to add to the indicator code some extra program items that allow to restore program code saved before multiple re-counting.


avatar
318
wackena 2010.08.04 19:01 

Try this: For open trades (not tested, but should work).

int total=OrdersTotal(); // number of open trades
double OpenLots=0;
double BuyTotal=0,SellTotal=0;

for(int i=0; i<total; i++)
   {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         { 
            if(OrderType()==OP_BUY)
               {
                  BuyTotal+=OrderLots(); // open Buy trades lots
               }
            if(OrderType()==OP_SELL)
               {
                  SellTotal+=OrderLots(); // open Sell trades lots
               }
            OpenLots+=OrderLots(); // total open lots
         }
   }



Back to topics list  

To add comments, please log in or register