How is the conversion and settlement of numbers (MT5) through the code please help

 

Hello

I want to correct a number to a whole number without a comma

MQL5 (MT5)

Example 1:

26275.233

To be converted to: 27000 

I mean, round it up to 1000 .

Example 2:

We have: 17125.331  Required to make: 18000


What is the code that does this?


(I'm new to learning, please help)


Thank you all

 
Nedal Burdukani:

Hello

What is the code that does this?

(I'm new to learning, please help)


Why don't you give it a try first, then ask for help with your solution, it is a much better way to learn

 
Paul Anscombe #:

Why don't you give it a try first, then ask for help with your solution, it is a much better way to learn

I tried, sir, but to no avail


please help me

 
i think you need to go from  17125.331 to 17.125331, then MathCeil this, which outputs 18.0 then you multiply by 10^??? to get as many zero as you need.
 
Enau #:
i think you need to go from  17125.331 to 17.125331, then MathCeil this, which outputs 18.0 then you multiply by 10^??? to get as many zero as you need.

Problem solved, thank you very much

I generated this code:


// thank you Enau

#include<Trade\Trade.mqh>// 
CTrade trade;

double say = 1;// 

void OnTick()
  {
//---------------------------
double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);//
double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);//
double MyLot = (1025 * 0.30) / 0.0020 ; Print("MyLOT  :  " ,MyLot); // 
double net = MyLot / 1000 ; Print("net  :  ",net); // 
double kes = ceil(net);Print("kes   : ",kes);//
double ret = kes / 100 ; Print("ret   :",ret);// 
//---------------------------
if(say==1){say=80;
trade.Buy(ret,NULL,Ask,Ask - (100 * _Point),Ask + (300 * _Point),"My Test");// BUY MARKET
}
  
  }
//+------------------------------------------------------------------+

Once again thank you

Reason: