Search for total Loser orders

 

Hi,

I want to run a cicle to look for the negative amount of money in open buy/sell orders.

Exemple, if I have 3 open buy orders, one losing 20 pips, other losing 50 pips and another losing 33 pips, which means at that point a total of 83 negative pips.

How can I get look for that 83 value, and for the total of open orders (3)?

Regards

 
Do you want to exclude a profitable order if there was one? What code have you got so far?
 
ubzen:
Do you want to exclude a profitable order if there was one? What code have you got so far?


It isn´t suppose to be there a profitable trade, because what I want is to place an order only if there are losing orders, to hedge it.

Untill now I haven´t any code, just considering how to get this part of the trading system.

 

Something like this:

int start(){
    //~~~~~~~~~~
    int Loss, Size;
    for(int i=OrdersTotal()-1;i>=0;i--){
        if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true
            && OrderSymbol()==Symbol()){
            //~~~~~~~~~~
            if(OrderProfit()<0){
                Size=Size+OrderLots();
                Loss=Loss+OrderProfit();
            }
        }
    }
    //~~~~~~~~~~
    Alert(Loss,"__",Size);
    //~~~~~~~~~~
return(0);}
 
ubzen:

Something like this:


I will try it.

Thank you very much.

 
ubzen:

Something like this:


It works fine. Thanks again. :)

Reason: