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

 
Igor Makanu:

cannot.

use iBars() to see the available history

SZZ: If I am not mistaken, in the tester, when you start the Expert Advisor is available 1000 bars, then with the generation of new data the number of bars will increase. The tester models the history of all the TFs to which it is addressed, ie, if you ran the test on H1 and during the test accessed the data in TF M1, then when you start it will be available for 1000 bars on H1, and therefore 60 * 1000 = 60,000 bars M1

you need to read more articles like this onehttps://www.mql5.com/ru/articles/1511

I have an idea how to do it.

You can make an EA start up and not trade for a month.

and the next month it will only start trading.

The history will be accumulated and the variance coefficient will be calculated before trading.


how do you like the method?



But how do I record that "the first month was not traded"...

I'll be testing on different periods.

I don't want to have to fix the date by hand all the time.

I don't want to keep correcting the date by hand.

 
multiplicator:

I've figured out how to do it.

you can make the EA start and not trade for a month.

This is roughly what you need for your problem, but again, use iBars() and you will know how much history is available to the EA in the tester

 

multiplicator:
счётчик, что ли включить, дней...

Igor Makanu:

but again use iBars() and you will know how much history is available to the EA in the tester

Exactly!

when iBars() becomes > 30 000 - calculate variance and then allow the EA to trade.

thanks to everyone who replied.

 

Hello ! Help for an inexperienced beginner trader! I have an EA but it does not have a stop loss! Who can add a stop loss to an EA (and if possible for free!)

 
Tem4ik:

Hello ! Help for an inexperienced beginner trader! I have an EA but it does not have a stop loss! Who can add a stop loss to an EA (and if possible for free!)


Post the code here (if it's not decompiled) and maybe someone will help.

 
#define  list "Cryptocurrency Market\\List.csv"

enum FILE_LOCATION
{
   LOCATE_TERMINAL = 0,
   LOCATE_COMMON = FILE_COMMON,
};

void GetLocalSource(FILE_LOCATION &dir)
{
   GetLocalList(FileOpenEx(list, FILE_WRITE|FILE_READ|FILE_CSV|dir));
}

int FileOpenEx(const string fname, int flags, int delimeter =';', uint codepage = CP_ACP)
{
   bool ex;
   if(flags > 4095)
      ex = FileIsExist(fname, FILE_COMMON);
   else
      ex = FileIsExist(fname);
   if(!ex) return -1;
   return FileOpen(fname, flags, delimeter, codepage);
}

bool GetLocalList(const int handle)
{
   if(handle == INVALID_HANDLE) {Print("Handle err: ", handle, " | ", GetLastError()); return false;}
...
}

I can't find the file viaFileIsExist, the function doesn't want to see it. I have already shuffled this file into both the general directory and the terminal directory - the result has not changed

2019.01.06 16:11:14.957 CoinMarketCap EURUSD,Daily: Handle err: -1 | 5020

The function that writes List.csv opens it via the same list macro substitution

What is the error?

 
Ilya Prozumentov:

I can't find the file via FileIsExist, the function doesn't want to see it. I have already shuffled this file into both the general directory and the terminal directory - the result has not changed

2019.01.06 16:11:14.957 CoinMarketCap EURUSD,Daily: Handle err: -1 | 5020

The function that writes List.csv opens it via the same list macro substitution

What is the error?

Try this#define list "Files\\\Cryptocurrency Market\\\List.csv"

The file should be in the Files folder

 
Vladimir Pastushak:

Try this#define list "Files\\\Cryptocurrency Market\\\List.csv"

File should be in the Files folder

Didn't work.


P.S Problem found, there is a space at the end of an already existing file name

 

Hello.

Can you please tell me how to determine the date (in date format) of the beginning of the week and the end of the week? I need the oscillator to zero out at the end of the week and start counting from zero at the beginning of the new week. At the moment I know how to set it to zero for each day, but I have no idea how to set it to zero for each week. This is how I reset every day.

void Calculate(int i)
  {
   double summ;
   datetime startTime  = StringToTime(TimeToString(Time[i],TIME_DATE)+" "+StartTime); // StartTime=00:10
   datetime endTime    = StringToTime(TimeToString(Time[i],TIME_DATE)+" "+EndTime);   // EndTime=23.50
   datetime currentTime= StringToTime(TimeToString(Time[i],TIME_DATE)+" "+TimeToString(Time[i],TIME_MINUTES));
//Print("Start = ",TimeToString(startTime,3));
//Print("End = ",TimeToString(endTime,3));
   if(CheckTimer(i,startTime,endTime,currentTime,0))
     {
      summ = MainBuffer[i+1];
      summ+= InfluenceBuffer[i];
      MainBuffer[i]=summ; 
     }
   else
     {
      summ=0.0;
      MainBuffer[i]=summ;
      }
  }

Thanks

 
Gerkl:

Can you please advise how to determine the date (in date format) of the beginning of the week and the end of the week?

//1. для времени datetime t
if(TimeDayOfWeek(t))==1) // Понедельник
if(TimeDayOfWeek(t))==5) // Пятница

//2. для текущего времени
if(DayOfWeek() = 1) // Понедельник
if(DayOfWeek() = 5) // Пятница

Most likely you need variant №1, then in the indicator in the calculation cycle, where you search for bars, you use the following structure:

if(TimeDayOfWeek(Time[i]))==1) // Понедельник
if(TimeDayOfWeek(Time[i]))==5) // Пятница
you have the right time in Time[i] after checking the condition
Reason: