Hello guys, i need help about my problem, i need filter profit with BUY position, like this :
I have 10 Buys Open Position, I need to Calculate 4 Buys Open Trde with highest profits, and order close after 4 buys profit 10$
Thank You for your respons
//---------------------------------------
double profit4buy()
{
double profit4buy=0;
int total=0;
for(i=OrdersTotal()-1; i>=0; i--)
{
os=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() &&OrderType()==OP_BUY)
{
total++;
if (total<=4) profit4buy+=OrderProfit()+OrderSwap()+OrderCommission();
}
}
return(profit4buy);
}
//===========================================
but i can't get squeezing 4 profts from highest profit to lowest profit
I have 10 Buys Open Position, I need to Calculate 4 Buys Open Trde with highest profits, and order close after 4 buys profit 10$
Thank You for your respons
//---------------------------------------
double profit4buy()
{
double profit4buy=0;
int total=0;
for(i=OrdersTotal()-1; i>=0; i--)
{
os=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() &&OrderType()==OP_BUY)
{
total++;
if (total<=4) profit4buy+=OrderProfit()+OrderSwap()+OrderCommission();
}
}
return(profit4buy);
}
//===========================================
but i can't get squeezing 4 profts from highest profit to lowest profit