Questions from Beginners MQL5 MT5 MetaTrader 5 - page 5

 
SNL:

Hi all. Can you tell me how to make a function so that it rounds a number like below.

Example.

1.23453 after rounding = 1.23455

1.23456 after rounding = 1.23460

1.23450 after rounding = 1.23450

So you want "1,2,3,4" in the last digit to be rounded to "5" and "6,7,8,9" in the last digit to be rounded to "0" while changing the second-to-last digit?
 
Yedelkin:
So you want "1,2,3,4" in the last digit to be rounded to "5" and "6,7,8,9" in the last digit to be rounded to "0" by changing the penultimate digit?
Yes.
 
SNL:

Hi all. Can you tell me how to make a function that rounds a number as below.

Example.

1.23453 after rounding = 1.23455

1.23456 after rounding = 1.23460

1.23450 after rounding = 1.23450

   double v=1.23450;
   double x=0.00005;
      
   v=MathCeil(v/x);
   v*=x;
   v=NormalizeDouble(v,5);
   Alert(DoubleToStr(v,5));

   //1.23453 после округления =  1.23455
   //1.23456 после округления =  1.23460
   //1.23450 после округления =  1.23450
 
Integer:

Thank you. Thank you very much.
 
Who can tell me how to build a channel using MA.
 

I want to learn how to use the timer function, but I can't figure out how it works.

I put EventSetTimer() in oninit

in deinit I writeEventKillTimer()

but when I insert void OnTimer(); into the code, the error 'OnTimer' - class type expected

In general, tell me how to use it?

 
SNL:
Who can tell me how to build a channel using MA.
Not on your topic? - https://www.mql5.com/ru/code/819
MA-Env
MA-Env
  • votes: 7
  • 2012.03.21
  • Leonid Basis
  • www.mql5.com
Индикатор Moving Average Envelopes.
 
openlive:

and when I insert void OnTimer(); into the code, the error 'OnTimer' - class type expected

How do you paste it? This is how it should work:
//+------------------------------------------------------------------+
//|                                                         test.mq5 |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property link      "http://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   EventSetTimer(60);
      
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
      
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   
  }
//+------------------------------------------------------------------+
 
Yedelkin:
How do you put it in? That's how it should work:
Thank you, it's working.
 

made a working expert

But I can't test the Expert Advisor in the tester. The matter is that the Expert Advisor takes data from a csv file. I put it in the special folder of the tester. and instructions prescribed in the file of the expert that it refers to this directory.... but they couldn't help me at the time. But the idea of running it through the tester remains.

I can help you, but please tell me what to put in what folder.

I put the Expert Advisor files and it works in normal trading

The pattern database file in MQL5\Files
Expert Advisor file in MQL5\Experts
Isewbar in MQL5\Include

Reason: