Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1431

 
Vitaly Muzichenko:

---

But it must be arrayed from the string in OnInit()

Thank you very much! I considered this option, but because of my illiteracy as a coder something went wrong)), but now if you allow me one more question.
All works, but there is a warning: implicit conversion from 'string' to 'number' , how to remove it? Is it possible?

 
Александр:
Thank you very much! I considered this option, but because of my illiteracy as a coder something went wrong)), but now if you allow me one more question.
Everything works, but I get a warning: implicit conversion from 'string' to 'number' , how do I get rid of it? Is it possible?

Re-posted the code

 
Awesome, super. Space success to you in your endeavours. Thank you for helping.
 
Maxim Kuznetsov:

That's the way it is around here... good code should be plenty.

We have others for that...))
 

Afternoon

Trying to create 2 files for MT4-MT5 copier:

string path, path1;
    int hend; 
    path=CopierNumber+"MasterOrdersV.csv";   
    hend=FileOpen(path,FILE_CSV|FILE_WRITE,',');
    if(hend>0)
    {
        FileWrite(hend,"Symbol","Ticket","Lot size","Direction","Price","StopLoss","Takeprofit","Open time");
        FileClose(hend);
    }
    path1=CopierNumber+"MasterOrders.csv";    
    hend=FileOpen(path1,FILE_CSV|FILE_COMMON|FILE_WRITE|FILE_SHARE_READ,',');
    if(hend>0)
    {
        FileWrite(hend,"Symbol","Ticket","Lot size","Direction","Price","StopLoss","Takeprofit","Open time");
        FileClose(hend);
    } 
When trying to read :

Same code in MT5 writes everything correctly:


Is it me having some kind of problem or has something crashed in MT4?

 
I think I've got it - the problem is in the Open Office, thanks
 

Colleagues, help with the algorithm and mathematical functions, you can just use mathematical functions, the task is to close a market position by 5 portions.

I.e. for example a market position of 10.24 lots or 5.12 lots should be covered with approximately equal parts of 5 parts. We can make one of the remaining ones larger than the others to cover the remaining volume after the first four positions have been closed.

This topic from the help of mate functions is not quite suitable, in my opinion, it needs something to complete.... HOW to optimally count lots of each of 5 shares (parts) to close a common position.

Возвращает вещественный остаток от деления двух чисел.



double  MathMod( 
   double  value,      // делимое 
   double  value2      // делитель 
   );
 

Параметры

value

[in]  Значение делимого.

value2

[in]  Значение делителя.

Возвращаемое значение

Функция MathMod рассчитывает вещественный остаток f от val / y таким образом, что val = i * y + f , где i является целым числом, f имеет тот же знак, что и val, и абсолютное значение f меньше, чем абсолютное значение y.

Примечание

Вместо функции MathMod() можно использовать функцию fmod().
 
Roman Shiredchenko:

Colleagues, help with the algorithm and mathematical functions, you can just use mathematical functions, the task is to close a market position by 5 portions.

I.e. for example a market position of 10.24 lots or 5.12 lots should be covered with approximately equal parts in total of 5 parts. We can make one of the remaining ones larger than the others to cover the remaining volume after the first four positions have been closed.

This topic from the help of mate functions is not quite suitable, in my opinion, it needs something - something to complete .... HOW to optimally count lots of each of the 5 parts (parts) to close a common position.

A division by 5 is a division by 5 :-)

lots_1to4=NormalizeLots(lots/5); // лоты для 1,2,3,4 ; округление лота сами добавите

lots5 = NormalizeLots(lots - lots_1to4*5); // для 5 - оставшиеся лоты

 
Maxim Kuznetsov:

a division by 5 is a division by 5 :-)

lots_1to4=NormalizeLots(lots/5); // лоты для 1,2,3,4 ; округление лота сами добавите

lots5 = NormalizeLots(lots - lots_1to4*5); // для 5 - оставшиеся лоты

О! Spc. Exactly - through the difference of rounded down and the starting total!!! Rounding through the same?

Возвращает ближайшее снизу целое числовое значение.



double  MathFloor( 
   double  val     // число 
   );
 

Параметры

val

[in]  Числовое значение.

Возвращаемое значение

Числовое значение, представляющее наибольшее целое число, которое меньше или равно val.

Примечание

Вместо функции MathFloor() можно использовать функцию floor().
 
Help make an alert for an indicator, can't find one with a signal
Files: