Errors, bugs, questions - page 6

 
Prival:

it says in the help.

intday_of_year;// number in a year (1 february is the 32nd day of the year)

For some reason it always comes out as 31 ((

the script attached

in the file

2010.02.01 00:00:00 143.832 143.839 143.758 143.771 186 2010 2 1 0 0 1 31

This is a mistake in the documentation. The numbering of days in a year starts from 0. Thank you.
 
stringo:
This is a mistake in the documentation. The numbering of days in a year starts from 0. Thank you.
I understand that it's more complicated, but it seems more familiar (to the layman. It's OK for the programmer). January 1 is 1 day of the year. It seems to me that the reference is correct.
 
Prival:
I understand that it is more complicated, but it seems to be more familiar (to the layman. To the programmer, it's OK). January 1 is the 1st day of the year. It seems right to me in the help.
We translate the standard system time structure to our MqlTime structure
 
For some reason I can't download the terminal from the server, it says "failed to download data from server", what's the problem?
 

Hello, can you help me translate from mt4 to mt5 function. I've translated it, but it's not right, if you're not hard, please send me the right code, I'm not very good at MQL. I'm just starting to learn it.

//+------------------------------------------------------------------+
#property copyright "2010, MetaQuotes Software Corp."
#property link"http://www.mql5.com"
#property version "1.00"
//--- input parameters

input double Lots=0.1;
input bool MM = true;
input double Risk = 10;


//+------------------------------------------------------------------+
//| Expert initialization function|
//+------------------------------------------------------------------+
int OnInit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function|
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{

}

//+------------------------------------------------------------------+
//| expert tick function|
//+------------------------------------------------------------------+
void OnTick()
{
if( MM )double Lots = LotSon(); //call LotSon function
}
//+------------------------------------------------------------------+
double LotSon()
{
double LotMin = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
double LotMax = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MAX);
double Lots = AccountInfoDouble(ACCOUNT_FREEMARGIN)/100000.0 * Risk;
double Lots = MathMin(Lotmax,MathMax(Lotmin,Lots));

if (LotMin < 0.1)Lots = NormalizeDouble(Lots,2);
else
{
if (LotMin < 1.0)Lots = NormalizeDouble(Lots,1);
else Lots = NormalizeDouble(Lots,0);
}
if (Lots < LotMin) Lots = LotMin;
if (Lots > LotMax) Lots = LotMax;
}

Automated Trading and Strategy Testing
Automated Trading and Strategy Testing
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 

How do you get the code in colour?

 
FEDOR_MQL:

How do you get your code coloured?

MQL5 Community article - User Memo:

The button is intended to insert the MQL source code into the text of the message. An empty window will appear as soon as you press it, in which you should insert the code and then press the Insert button. To cancel the code insertion, press the Cancel button.

It is not recommended to make code bold in order to highlight certain chunks in a meaningful way. The point is that monospace fonts are displayed differently in different operating systems and browsers. For example, Windows Vista uses Consolas monospace font, which has a bold font for size 10 that is almost indistinguishable from a regular font.

 
FEDOR_MQL:

Hello, can you help me translate from mt4 to mt5 function. I've translated it, but it's not right, if you're not hard, please send me the right code, I'm not very good at MQL. I'm just starting to learn it.


 //+------------------------------------------------------------------+
#property copyright "2010, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
//--- input parameters

input double   Lots=0.1;
input bool     MM = true;
input double   Risk = 10;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
  return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if( MM ) Lots = LotSon();      //вызов функции LotSon 
  }
//+------------------------------------------------------------------+
double LotSon()
{
  double LotMin     = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
  double LotMax     = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MAX);
  double LotStep    = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);
  double Lot        = AccountInfoDouble(ACCOUNT_FREEMARGIN)/100000.0 * Risk;
  Lot               = MathMin(Lotmax,MathMax(Lotmin,Lot));
  
  if (Lot < LotMin) Lot = LotMin;
  if (Lot > LotMax) Lot = LotMax;
  // Вариант первый
  switch(LotStep)
  {
   case 0.01: return(NormalizeDouble(Lot,2));
   case 0.1 : return(NormalizeDouble(Lot,1));
   case 1.0 : return(NormalizeDouble(Lot,0));
  }
  // Вариант второй
  // if (LotStep == 0.01)return(NormalizeDouble(Lot,2));
  // if (LotStep == 0.1) return(NormalizeDouble(Lot,1));
  // if (LotStep == 1.0) return(NormalizeDouble(Lot,0));
  // Вариант третий
  // if (LotStep == 0.01)return(NormalizeDouble(Lot,2));
  // else if (LotStep == 0.1) return(NormalizeDouble(Lot,1));
  // else if (LotStep == 1.0) return(NormalizeDouble(Lot,0));
  
}
 

All right, let's give it a try. Thank you all! Am I even asking these questions? Or do I need to go somewhere else? Thanks in advance for the answer.

 

And at this stage of development: parameters, function call and function itself should show compile-time errors or not. If so, why? I have errors showing

Документация по MQL5: Основы языка / Функции / Вызов функции
Документация по MQL5: Основы языка / Функции / Вызов функции
  • www.mql5.com
Основы языка / Функции / Вызов функции - Документация по MQL5
Reason: