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

 

Good afternoon,

Is there any way to change the directory for writing/reading files from "Tester/Files" to "MQL/Files" when the Expert Advisor is working with these files during testing?

 
Asa saas:

Good afternoon,

Is it possible to change the reading/writing directory from "Tester/Files" to "MQL/Files" when Expert Advisor uses these files during testing?

With MQL - no way, only through WinAPI.

 

Thank you for your reply!

 
PolarSeaman:

How do I calculate the lot volume in increments? If deposit =1000, lot = 0.1, deposit became 2000 lot = 0.2. That is, if the deposit is 1500 or 1700, the lot does not increase.

lot = MathCeil(depo / 1000) * 0.1;
 
Ihor Herasko:

Not with MQL tools, only with WinAPI.

Asa saas:

Thanks for the answer!

In this case you'd better use the FILE_COMMON flag and the files will be available both from the tester and the terminal. Only problems may occur when testing on the network. But personally I haven't tested it.

FileOpen - Файловые операции - Справочник MQL4
FileOpen - Файловые операции - Справочник MQL4
  • docs.mql4.com
[in]  Имя открываемого файла, может содержать подпапки. Если файл открывается для записи, то указанные подпапки будут созданы в случае их отсутствия. [in]  значение, используемое в качестве разделителя в txt или csv-файле. Если для csv-файла разделитель не указан, то по умолчанию используется ";". Если для txt-файла разделитель не указан, то...
 

Taras Slobodyanik:

lot = MathCeil(depo / 1000) * 0.1;

Let's do the math:

Deposit = 1,700. Divided by 1,000 we get 1.7 and rounded to the nearest integer on top, we get 2.

Multiply by 0.1 and the result is not what you want.

Apparently it is better to take rounding to the nearest lower integer MathFloor

MathFloor - Математические функции - Справочник MQL4
MathFloor - Математические функции - Справочник MQL4
  • docs.mql4.com
MathFloor - Математические функции - Справочник MQL4
 
PolarSeaman:

No, no, with a deposit of 1100, the lot will be 0.11, and I need the lot not to increase up to 2000. How to specify a step =1000 in settings?

I have corrected it.

double percentLot = 0.01,
       lot = NormalizeDouble(MathFloor(AccountInfoDouble(ACCOUNT_BALANCE)*percentLot/10)/10, 1);

Although the principle is there, and this is a nuance

 
Alexey Viktorov:

Let's do the math:

Deposit = 1,700. Divided by 1,000 we get 1.7 and rounded to the nearest whole number on top, we get 2.

Multiply by 0.1 and the result is not what you want.

Apparently it's better to round to the nearest lower integer MathFloor

or instead of 1000, use 1999.99 )

1000 and 0.1 are external variables.

 
And why is everyone clinging to 0.1. Today a man wants 0.1, tomorrow he wants 0.5. You have to base it on the percentages. There is no point in being rigidly bound by intelligence.
 

Thank you, I did so:

   input double _lot=0.1;
   input int _depo=1000;
//***************************
   lot=MathFloor(AccountInfoDouble(ACCOUNT_BALANCE)/_depo)*_lot;
   lot=NormalizeDouble(lot,2);

I hope I put_depo ofint type correctly.

Reason: