Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1258

 
DKarpoff:

I need to loop through the candles in the indicator, but not from the 0th but from the first candle of the previous week.

for(int i=0; i<rates_total; i++) - these are all bars

and we need something like:

X=(IndexFirstTradingWeek(EURUSD,H1))+120;

for(int i=(rates_total-X); i<rates_total; i++)

You want to know in the indicator index of the first candle of some day at the current timeframe? (the current timeframe is the timeframe on which the indicator is running)

 

I've said the same thing in five ways already, are you kidding me?

For my EURUSD H1 broker, the index of the first hourly candle for this trading week is now 100029.

Does MQL5 have a function that can send me the number of H1 timeframe and EURUSD? Both today and tomorrow and Friday night?
 
DKarpoff:

I've said the same thing in five ways already, are you kidding me?

For my broker on EURUSD H1 the index of the first hourly candle for this trading week is now 100029.

I advise you to take it easy and remember that this is a technical forum. It may all seem strange to you, but I ask such clarifying questions because depending on the situation, the solution can be VERY, VERY different.

So to repeat the question:

Forum on trading, automated trading systems and testing trading strategies

FAQ from Beginners MQL5 MT5 MetaTrader 5

Vladimir Karputov, 2020.11.02 10:52

Do you want to know in an indicator the index of the first candle of some day at the CURRENT TIMFrame?(current timeframe - the timeframe of the indicator)


 
Vladimir Karputov:

I advise you not to get too excited and remember that this is a technical forum. This may sound strange to you, but I am asking these clarifying questions because depending on the situation, the solution can be VERY, VERY different.

So to repeat the question:


No, you need a function that returns the day of the week, or a function that returns the index of the first candle on Monday. on the current one, whichever one I specify...
Документация по MQL5: Константы, перечисления и структуры / Состояние окружения / Информация об инструменте
Документация по MQL5: Константы, перечисления и структуры / Состояние окружения / Информация об инструменте
  • www.mql5.com
Для получения текущей рыночной информации служат функции SymbolInfoInteger(), SymbolInfoDouble() и SymbolInfoString(). В качестве второго параметра этих функций допустимо передавать один из идентификаторов из перечислений ENUM_SYMBOL_INFO_INTEGER, ENUM_SYMBOL_INFO_DOUBLE и ENUM_SYMBOL_INFO_STRING соответственно. Некоторые символы (как правило...
 

Here's everything I found in the help about the days of the week:

The ENUM_DAY_OF_WEEK enumeration is used to specify the day of the week.


There's an enumeration, but it's not clear where it's used... Poke your nose in if there is one.

 

Good afternoon.

Question of the following kind...

In MQL4 the FAQ clearly says that if you call the same indicator with the same set of input parameters from different places in a code, the first call of the indicator is created in the memory, the indicator is calculated (you can receive data from it), next time you call the same indicator with the same set of input parameters, no new indicator copy is created in the memory, it just takes data from the already created and calculated indicator.

Question: What is the situation in MQL5?
The question arose because of this:

We have an Expert Advisor that calculates two indicators through iCustom (let's call them "Indicator A" and "Indicator B"). Indicator B" itself in its code also calls the calculation of "Indicator A" with the same set of input parameters. At the same time, the "Journal" tab of MT5 displays 3 messages: one on the loading of "Indicator B" and 2 on the loading of "Indicator A". Does it mean that "Indicator A" is calculated twice?

I tried to print indicator handles that are received during iCustom calls - it is of no use - it seems that handle numbering is different (local) for each code and therefore the comparison of handles gives nothing.

 
satorifx:

Good afternoon.

Question of the following kind...

In MQL4 the FAQ clearly says that if you call the same indicator with the same set of input parameters from different places in a code, the first call of the indicator is created in the memory, the indicator is calculated (you can receive data from it), next time you call the same indicator with the same set of input parameters, no new indicator copy is created in the memory, it just takes data from the already created and calculated indicator.

Question: What is the situation in MQL5?
The question arose because of this:

I have an Expert Advisor that calculates two indicators through iCustom (let's call them "Indicator A" and "Indicator B"). Indicator B" itself in its code also calls the calculation of "Indicator A" with the same set of input parameters. At the same time, the "Journal" tab of MT5 displays 3 messages: one on the loading of "Indicator B" and 2 on the loading of "Indicator A". Does it mean that "Indicator A" is calculated twice?

I tried to print indicator handles that are received when calling iCustom - it is of no use - it seems that handle numbering is different (local) for each code and therefore the comparison of handles gives nothing.

In MQL5, any indicator has to be created once by obtaining a handle of the indicator. And this must be done in OnInit().

 
DKarpoff:

Here's everything I found in the help about the days of the week:

The enumeration ENUM_DAY_OF_WEEK is used to specify the day of the week.


There's an enumeration, but it's not clear where it's used... Poke your nose in if there is one.

TimeToStruct() will help you )))

 
Vladimir Karputov:

In MQL5 any indicator must be created once by getting the indicator handle. And you have to do it in OnInit().

I know what you told me and it is done exactly the same way: in Expert Advisors and in all indicators. I was not asking about this.

 
Сергей Таболин:

TimeToStruct() will help you )))

Thank you kind man =) Just what you need!

Reason: