Close Profitable Trades Only, at Profit Target - page 2

 
af1:


Here is an example Raptor. I have 4 orders with 97.9 of profit. So If my profit target is 25, and the condition is "CloseProfitableTradesOnly" true, then these 4 orders should close. But is not closing any order.


your profit here is -59.80 So you forget something your loosses
 
RaptorUK:
No, the total profit has to be greater than equal to 25.0, yours is -59.80

What you said is, in fact, the original function of this ea, I understand that. But as I mentioned before, what I'm looking is to close only the profitable orders when together reaches 25. And I mean for together: Only the positive orders. The negative orders wil not close until reaches the condition of 25, and so on.

Do you think this is possible?

 
deVries:

your profit here is -59.80 So you forget something your loosses


Hi deVries, thank you for your help.

I know that my total profit/loss is -59.80, but if I have positive orders, then I can close it with profit, and that is what Im looking. To close only the profitable orders, (above 1 usd), when reaches 25 usd.

 
af1:

What you said is, in fact, the original function of this ea, I understand that. But as I mentioned before, what I'm looking is to close only the profitable orders when together reaches 25. And I mean for together: Only the positive orders. The negative orders wil not close until reaches the condition of 25, and so on.

Do you think this is possible?

Yes, of course it's possible.
 
RaptorUK:
Yes, of course it's possible.


I'm not an expert at coding, but what I do know is that this ea has the elements to do that function. I just don't know what to change or add. Could you help me please?
 
af1:

I'm not an expert at coding, but what I do know is that this ea has the elements to do that function. I just don't know what to change or add. Could you help me please?
If you want a hack job someone can do it in a few minutes, if they hack it right it will work, if not it will need a few iterations and you will take maybe an hour of someone life. If you want it done properly then a new function or two will need to be designed and a few options adding . . . this will take a few hours of someone's life.
 

I'm far from being an expert

But it seems to me that you need to be totalling only the trades that are in profit

You could try this.

for(int i=0;i<OrdersTotal();i++)
      {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) continue;
         if(OrderType()==OP_BUY)  
         {
            OrdersBUY++;
            BuyLots += OrderLots();
            double ThisTradeProfit=OrderProfit() + OrderCommission() + OrderSwap();
            if(ThisTradeProfit>0)
            BuyProfit += ThisTradeProfit;
         }
         if(OrderType()==OP_SELL) 
         {
            OrdersSELL++;
            SellLots += OrderLots(); 
            ThisTradeProfit=OrderProfit() + OrderCommission() + OrderSwap();
            if(ThisTradeProfit>0)
            BuyProfit += ThisTradeProfit;
         }
      }           
 
RaptorUK:
If you want a hack job someone can do it in a few minutes, if they hack it right it will work, if not it will need a few iterations and you will take maybe an hour of someone life. If you want it done properly then a new function or two will need to be designed and a few options adding . . . this will take a few hours of someone's life.


I know Raptor, I've already spent almost two days trying to figure out this ea, searching and trying changes before asking for help. So I appreciate your time and knowledge. I'll keep trying to make it works. Any other suggestions are welcome.

 
GumRai:

I'm far from being an expert

But it seems to me that you need to be totalling only the trades that are in profit

You could try this.






Hi GumRai, thanks for your time. I've already tried with your changes, but orders keep closing at 1. In other words, profitable orders are not waiting to reach 25.
 

This is another example of what I'm looking:



Any idea would be very appreciated.

Reason: