Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1573

 
Artyom Trishkin #:

Why aren't there arrays in the structure?

To have a relationship between the cells of arrays

You can write it this way, but it is not quite readable in use

double Ind[][3];
// Ind[][0] инд 1
// Ind[][1] инд 2
// Ind[][2] инд 3

P.S. Reworked, I will keep the theoretical logical chain in the future

struct aIND {
  double RSI[];
  double CCI[];
  double MACD[];
};
aIND Ind;

--

THANK YOU!

 
Hello! I am creating an Expert Advisor that sends signals. The search of the trading situation is written in theOnTick function . In order to prevent signals from repeating, I used the following check:
   datetime Curr_bar = iTime(SymbolName(i,true),periods[x],0);     
   static datetime SignalTime = Curr_bar;   

if(//code search signal && SignalTime != Curr_bar){
Print("Signal buy");
SignalTime = Curr_bar;
}
Recently this check stopped working. Failures began to appear (signals are repeated in a huge number)
Later I found a code with a slightly different check from another programmer:
   int currBars = iBars(SymbolName(i,true),periods[x]);
   static int prevBars = currBars;
   if (prevBars == currBars) return;
   prevBars = currBars;
The problem remains the same.Is there any other way to make this check?
The essence of the check is that the Expert Advisor analyses the situation once, sends a signal to the Print or Alert function and does not touch it anymore.


Документация по MQL5: Основы языка / Функции / Функции обработки событий
Документация по MQL5: Основы языка / Функции / Функции обработки событий
  • www.mql5.com
В языке MQL5 предусмотрена обработка некоторых предопределенных событий . Функции для обработки этих событий должны быть определены в программе...
 
Igor168 OnTick function . In order to prevent signals from repeating, I used the following check:
Recently this check stopped working. Failures began to appear (signals are repeated in a huge number)
Later I found a code with a slightly different check from another programmer:
The problem remains the same. Is there any other way to make this check?
The essence of the check is that the Expert Advisor analyses the situation once - sends a signal to the Print or Alert function and does not touch it anymore
.
//+------------------------------------------------------------------+
void  OnTick()
  {
   if(NewBar())
      Print("NewBar");
  }
//+------------------------------------------------------------------+
bool NewBar()
  {
   static datetime nextTime = 0;
   if(nextTime <= TimeCurrent())
     {
      int perSec = PeriodSeconds(PERIOD_CURRENT);
      nextTime = TimeCurrent() - TimeCurrent() % perSec + perSec;
      return true;
     }
   return false;
  }
//+------------------------------------------------------------------+

Try this.

 
Aleksandr Slavskii #:

Try this.

I think it is necessary to supplement it.

The specified NewBar() will work correctly only when called from OnTick(), in case of calling from other functions OnTimer(), OnChartEvent() errors are possible.

When calling not from OnTick() instead of TimeCurrent() it is better to use the time of the last tick of the checked symbol.

 
Aleksandr Slavskii #:

I think it needs to be supplemented.

The specified NewBar() will work correctly only when called from OnTick(), in case of calling from other functions OnTimer(), OnChartEvent() errors are possible.

When calling not from OnTick() instead of TimeCurrent() it is better to use the time of the last tick of the checked symbol.

Got it. Thank you for the answer

 

I want to read the terminal log file. It is located in logs\18112024.log in the root of the terminal above the MQL5 folder.

I made a symbolic link so as not to bother with access to files outside the sandbox. Using mklink

So I need the Files\Logs\20241118.log file of today.

I can't open it:

 int filehandle=FileOpen("Logs\\"+"20241118.log",FILE_READ|FILE_SHARE_READ|FILE_TXT);

Although yesterday's file opens:

 int filehandle=FileOpen("Logs\\"+"20241117.log",FILE_READ|FILE_SHARE_READ|FILE_TXT);

Maybe I've messed with the flags ? How to open today's file where the terminal writes logs ?

 

It's a good idea that comes afterwards. Opened

 int filehandle=FileOpen("Logs\\"+FileNameLog,FILE_READ|FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_TXT);
 
Good afternoon

I have a robot optimization routine that first uses the standard genetic method from the strategy tester,
and then further improves the obtained result by cyclic sequential optimization of each parameter, using a strategy tester.
This takes quite a lot of laptop time.

Please tell me, is it possible to launch this process somewhere on servers rented via the Internet?


I thank you in advance for any advice.

Best regards, Alexander
 
klycko #:
Good afternoon!

I have a robot optimisation procedure that first uses the standard genetic method from the strategy tester,
and then improves the result by cyclic sequential optimisation of each parameter using the strategy tester.
This takes quite a bit of notebook time.

Can this process be run somewhere on internet rented servers?


I am grateful in advance for any advice.

Sincerely, Alexander
From my experience, I will say that you are doing tinkering. In the real world will drain.
 
Roman Kutemov #:
In my experience, I will say that you are in the business of tinkering. In real life, it's going to be a drain.

With this kind of optimisation = 100% drain.