[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 169

 
FAQ:

For each order: calculate the difference between the opening price and the price you need, multiply by the pip value, and by the order volume.

Add up.

This is a bit tricky.

Go through the open orders and sum up:

OrderProfit() + OrderCommission() + OrderSwap();
 
Uh-huh, and where do we come to ? read the question carefully. it's about calculating the profit, at a certain point, not the current one.
 
hedger:

Possibly.

But if the reason is that the question is about MT5 and not MT4, then I was guided by this list:


It's just luring us to a fiver with its advertising... :-) For more - See Treugi coming up.
 
FAQ:
Uh-huh, and where do we come to ? read the question carefully. it's about calculating the profit, at a certain point, not the current one.
Mm-hmm. Right. Sorry didn't get it right.
 

It seems so... unfortunately, it's problematic to check it on the tester (or I'm so sleepy I can't figure out how), check?

double AcountProfitEx (double Price) {
   double PipsPrice = MarketInfo(Symbol(),MODE_TICKVALUE)/(MarketInfo(Symbol(),MODE_TICKSIZE)/MarketInfo(Symbol(),MODE_POINT));
   double ProfitSum = 0;
   for (int i = OrdersTotal(); i > 0; i--) {
      OrderSelect(i, SELECT_BY_POS);
      if ((OrderType() == OP_BUY) || (OrderType() == OP_SELL)) {
         ProfitSum += (OrderOpenPrice()-Price)*PipsPrice*OrderLots();
      }
   }
   return (ProfitSum);
}
 

Good afternoon.

How do I check if a number is a whole number?

e.g. as a result of dividing from one number by another

 
Stells:

Good afternoon.

How do I check if a number is a whole number?

For example, the result of dividing from one number by another?


bool CheckInt(double Value, double Delta){
   if (MathAbs(Value-MathRound(Value))<Delta) 
       return(true);
   return(false);
}

You can go like this

Delta - Set error

 
if(MathMod(input,1.0)==0){
    // значит input целое
}
 
Vinin:

I want to commit 2 trades in the history and perform an action on the third one, can you do this :

int Orders=HistoryTotal(); // history orders total
int Kol_Orders=0; // number of trades

for(int s=Orders-1;s>=0;s--)
{
if(OrderSelect(s,SELECT_BY_POS,MODE_HISTORY)==false)
{
Print("History error!");
break;
}
if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL || OrderMagicNumber()!=MAGIC)
continue;
Kol_Orders++;

}
bool CheckInt(double Value, double Delta){

Value=Kol_Orders/2;

delta =0.001;
if (MathAbs(Value-MathRound(Value))<Delta)
return(true);
return(false);
}

 
FAQ:

is it ok ?

int Orders=HistoryTotal(); // history orders total
int Kol_Orders=0; // number of orders

for(int s=Orders-1;s>=0;s--)
{
if(OrderSelect(s,SELECT_BY_POS,MODE_HISTORY)==false)
{
Print("History error!");
break;
}
if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL || OrderMagicNumber()!=MAGIC)
continue;
Kol_Orders++;

}

if(MathMod(Kol_Orders/2,1.0)==0){
// input integer
}