Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1310

 

MqlRates rates[];

rates[0].open> rates[0].close

Please advise how to check this condition on the current timeframe and on several more timeframes at once, two, three, five. How does it affect the performance of testing? I would be glad to receive a link to a multiframe EA or an MT5 indicator.

 
Николай К:

MqlRates rates[];

rates[0].open> rates[0].close

Please advise how to check this condition on the current timeframe and on several more timeframes at once, two, three, five. How does it affect the performance of testing? I would be glad to receive a link to a multiframe EA or an MT5 indicator.

Array rates_tf_**[] for each TF and CopyRates also for each TF to the appropriate structure array. How it affects speed of testing... That's another question. But there is nothing else. Or maybe I just do not know...
 


THE CODE

FileWrite(file_handle, Period());

on a 5 minute timeframe it shows 5

AF 15 min =15

And on TF 1h =1536

4ч = 16388

Why so?

 
Aleksei Skrypnev:


THE CODE

on a 5 minute timeframe it shows 5

AF 15 min =15

And on TF 1H =1536.

Why so?

First we look atPeriod()

...The value can be one of valuesof the enumerationENUM_TIMEFRAMES:

Identifier

Description

PERIOD_CURRENT

Current period

PERIOD_M1

1 minute

PERIOD_M2

2 minutes

PERIOD_M3

3 minutes

PERIOD_M4

4 minutes

PERIOD_M5

5 minutes

PERIOD_M6

6 minutes

PERIOD_M10

10 minutes

PERIOD_M12

12 minutes

PERIOD_M15

15 minutes

PERIOD_M20

20 minutes

PERIOD_M30

30 minutes

PERIOD_H1

1 hour

PERIOD_H2

2 hours

PERIOD_H3

3 hours

PERIOD_H4

4 hours

PERIOD_H6

6 hours

PERIOD_H8

8 hours

PERIOD_H12

12 hours

PERIOD_D1

1 day

PERIOD_W1

1 week

PERIOD_MN1

1 month


Note: "one of the values of PERIOD ...". That is, it can be PERIOD_H6 or PERIOD_M1 or any value from PERIOD. But the internal representation of the enumeration should not interest anyone at all. Today it is '15' and tomorrow it can be '15478899662'. But you, as a programmer, should not care at all - you should work with values (PERIOD_M4, PERIOD_M15 ...), not with the internal representation.

Документация по MQL5: Проверка состояния / Period
Документация по MQL5: Проверка состояния / Period
  • www.mql5.com
Period - Проверка состояния - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Vladimir Karputov:

First look atPeriod()

...The value can be one ofENUM_TIMEFRAMESenumeration values:



Note: "one of the values of PERIOD ...". So it can be PERIOD_H6 or PERIOD_M1 or any value from the enumeration. But the internal representation of the enumeration shouldn't interest anyone at all. Today it is '15' and tomorrow it can be '15478899662'. But you, as a programmer, shouldn't care about this at all - you must work with values (PERIOD_M4, PERIOD_M15 ...), not with the internal representation.

I thought something more clear would be written to the file)

You can't write something more clear (just like Perod_H1) to a file in a simple way?

 
Aleksei Skrypnev:

I thought something clearer would be written to the file)

You can't write something more understandable (just like Perod_H1) to a file in a simple way, can you?

If you need it to be very clear - write it as text'PERIOD_H1' and the like into the file.

 

Good day to all! What a problem! I was testing an EA on MT4, tested it all day long, in the end I saw that in the evening there was no memory left on the hard drive, I immediately realized that it was because of the tests, I decided to clean it up, went to the MetaQuotes folder in the Windows , and deleted a lot of things there, as a result all platforms were lost, both MT4 and MT5, 10 pieces in total, they run, but they are completely "clean" - no indicators from the market, no EAs, nothing! i really needed one advisor in one mt5 terminal, i didn't save a copy, no more activations, what should i do ?

I decided to use the program to restore deleted files, i managed to restore the EA file by putting it in the expert folder during the update and the terminal just does not see it, and i can't download it from the Market account, it says installation failed!

Files:
 

Please help me with a problem!

I'm just learning how to write code, so please be lenient with my lack of literacy.

I need help in understanding theOnChartEvent function, which updates graphical objects in the chart after a timeframe change or change of the settings in the indicator menu. In case of indicator closing I will completely delete all graphical objects of this indicator from the chart.

I understand that you have to delete the graphical objects first and then create them again. Butif the objects were deleted, there's no access to its properties and then how to re-create these objects....... Or maybe I don't understand it? Or maybe there is another way - updating graphical objects on the chart ?

Please write an example with comments on how to do it.


 
Sprut 185:

Please help me with a problem!

I'm just learning how to write code, so please be lenient with my lack of literacy.

I need help in understanding theOnChartEvent function, which updates graphical objects in the chart after a timeframe change or change of the settings in the indicator menu. In case of indicator closing I will completely delete all graphical objects of this indicator from the chart.

I understand that you have to delete the graphical objects first and then create them again. Butif the objects were deleted, there's no access to its properties and then how to re-create these objects....... Or maybe I don't understand it? Or maybe there is another way - updating graphical objects on the chart ?

Please write an example with comments on how to do it.


Don't consider it rude, but there are all examples in the documentation. You just need to pay attention to the ObjectSet*** functions which change the parameters of a graphical object.

Документация по MQL5: Графические объекты / ObjectSetDouble
Документация по MQL5: Графические объекты / ObjectSetDouble
  • www.mql5.com
ObjectSetDouble - Графические объекты - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Alexey Viktorov:

Not to be rude, but the documentation has all the examples. You just need to pay attention to the ObjectSet*** functions which change the parameters of the graphical object.

Thank you for your participation.

Unfortunately the ObjectSet*** function was not suitable for my task.

I solved the problem myself using the OnDeinit() function.
void OnDeinit(const int reason)
  {
   ObjectsDeleteAll (0, -1, -1);
  }

Now everything works as it should.