Questions from Beginners MQL5 MT5 MetaTrader 5 - page 927

 
Seric29:

I mean if the condition is true, then do 2 identical actions e.g.

I have declared variables and nothing is done except either this actionPrice_UrNij = Bar_Cl[iHgCL]>Bar_Op[iHgOP] ? Bar_Cl[iHgCL]:Bar_Op[iHgOP]; or this actionPrice_UrVerh = Bar_Cl[iLwCL]<Bar_Op[iLwOP] ? Bar_Cl[iLwCL]:Bar_Op[iLwOP]; how to make it perform 2 identical actions with both top and bottom levels by condition. May someone suggest how to write it in a shorter form?

1. Such code is very difficult to read.

          int iHgCL=iHighest(_Symbol,PERIOD_D1,MODE_CLOSE,4,qt+1); int iHgOP=iHighest(_Symbol,PERIOD_D1,MODE_OPEN,4,qt+1);

Hardly anyone would search for a variable declaration outside the beginning of a line.

2. You just have to call the function of building levels twice inside the if block

vs_Line_TR( Line_TR, iTime(_Symbol,PERIOD_D1,qt+2),  Price_UrNij, iTime(_Symbol,PERIOD_D1,qt), Price_UrNij, clrGreen, DRAW_LINE, 2, false, false);
vs_Line_TR( Line_TR, iTime(_Symbol,PERIOD_D1,qt+2),  Price_UrVerh, iTime(_Symbol,PERIOD_D1,qt), Price_UrVerh, clrGreen, DRAW_LINE, 2, false, false);
 

what is the difference in use? what is the nuance?

MqlDateTime dt;
datetime time=TimeTradeServer(dt)

и

MqlDateTime tm;
TimeToStruct(TimeTradeServer(),tm);
 
Fast528:

what is the difference in use? what is the nuance?

There is probably no difference.

 
Alexey Viktorov:

There is probably no difference.

I take it that the first case is if you want to use the time variable and the structure, and the second case is just the structure data?

 
Fast528:

I take it that the first case is if you want to use the time variable and the structure, and the second case is just the structure data?

I didn't pay attention to the time variable.

What is it for? After all, it doesn't cost anything to translate the structure into time. But in this case there will be no memory reserved for the variable.

Or if we need only time without division into parts, why should we reserve memory for the structure?

 
Alexey Viktorov:

I didn't pay attention to the time variable.

What's it for? It doesn't cost anything to translate the structure into time. But in this case there will be no memory reserved for the variable.

Or if you need only time without division, why would I need to reserve the memory for the structure?

I need the indicator to display entry/exit positions on the chart and draw a line between them, for example, on the period of today minus 1 day, like it is usually done in an indicator or robot?

 

Running a test.

The program opens the file in OnInit():

CFileTxt file;
int file_handle=file.Open("file_name.lic",FILE_READ);
if(file_handle==INVALID_HANDLE)
     {      
      return INIT_FAILED;
     }

Not only does it not find the file in the folder, but it also deletes another file in the MQL5\Files folder of the testing agent after testing. There are two files in total that are deleted at startup.

Error5004 on FileOpen().

The problem is only in the tester.

Тестирование стратегий - Алгоритмический трейдинг, торговые роботы - MetaTrader 5
Тестирование стратегий - Алгоритмический трейдинг, торговые роботы - MetaTrader 5
  • www.metatrader5.com
Тестер стратегий позволяет тестировать и оптимизировать торговые стратегии (советники) перед началом использования их в реальной торговле. При тестировании советника происходит его однократная прогонка с начальными параметрами на исторических данных. При оптимизации торговая стратегия прогоняется несколько раз с различным набором параметров...
 
Juer:

Running the test.

The program opens the file in OnInit():

Not only does it not find the file in the folder, but it also deletes another file in the MQL5\Files folder of the testing agent after testing. There are two files in total that are deleted at startup.

Error5004 on FileOpen().

The problem is only in the tester.

The agent folders are being cleaned up. This is correct. If you need to tuck in a previously saved file, use the reference to the file saved in the shared folder.


Example from my codes:

//--- STEP 6
   if(m_file_txt.Open(InpFileName,FILE_WRITE|FILE_COMMON)==INVALID_HANDLE)
 
Vladimir Karputov:

The agents' folders are being cleaned out. This is correct. If you need to tuck in a previously saved file, use the reference to the file saved in the shared folder.


An example from my codes:

What shared folder? I don't use it at all. I always start in portable mode. I have everything in the installation folder.

 
Juer:

What shared folder? I don't use it at all. I always run in portable mode. I have everything in the installation folder.

Shared folder:FILE_COMMON. Search, read. Thinking.