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

 
YarTrade:

That's what I read. I wanted to make sure I understood what was written correctly.

Gentlemen, do I understand correctly that iVolume returns the volume of trades made per tick?

No, not correctly. iVolume returns the tick volume of the specified bar. I.e. the amount of changes of Ask and Bid prices.

Observing the proposed indicator, you can see it very well.

 

Hello, I am still trying to fix the code from the custom indicator to the EA, I started to analyze the parts and found the IndicatorCounted() function, how can it be replaced in the EA code?

In addition to this function, the indicator uses timeseries High and Low, and in the indicator and the EA, the code compiles and runs, but in the EA at the first tick it fails critical error, apparently going beyond the array.....

I read about indicators, how to trace this zero bar? without this function, include timer and close bars by timeframe?

 
ijonhson:

Hello, I am still trying to fix the code from the custom indicator into EA, I started to analyze the parts and found the IndicatorCounted() function, how it can be replaced in the EA code?

In addition to this function, the indicator uses timeseries High and Low, and in the indicator and in the EA, the code compiles and runs, but in the EA at the first tick is a critical error, apparently going beyond the array.....

There is no need to change it. It's a function that determines the number of bars already counted. If you have an irrepressible desire to do it in ... But in this case, we should consider only the last bar and ignore all history bars.

 
ijonhson:

trying to correct code from a custom indicator into an EA


What do you mean by that? Can we talk about moving code from an indicator to an EA?

IndicatorCounted(), how can it be replaced in the EA code?

Do you know how an indicator differs from an EA? If so, why do you need this function in your EA?


I read about the indicators, how can we track this zero bar? without this function, switch on the timer and close the bars by timeframe?

I think there is a question of cause and effect. You have set the task incorrectly, better explain what you want to achieve and they will tell you the right course of action.

 
Alexey Viktorov:

It does not need to be changed in any way. It is a function that determines the number of bars already counted. If you have an irrepressible desire to do it in ... Of course, we can move the market state recalculation to the Expert Advisor, but in this case we should count only on the last bar and ignore all history bars.


"It doesn't need to be changed", i.e. it works correctly with onTick in Expert Advisors like it does with onCalculate in indicators?

 
Nikolay Ivanov:

What do you mean by that? Is it about transferring code from an indicator to an EA?

Do you know how an indicator differs from an EA? If so, why do you need this function in your EA?


Yes, I transferred the code, that's right.

I need an array of indicator nodes for analysis on every tick

 
ijonhson:

Yes, the code transfer is correct.

I need an array of indicator nodes for analysis on each tick preferably


If you need indicator values in your EA, you don't need to copy the code of the indicator to the EA, you don't even need the code of the indicator. You need to request the indicator values from the EA, this is done with this functionhttps://docs.mql4.com/ru/indicators/icustom

iCustom - Технические индикаторы - Справочник MQL4
iCustom - Технические индикаторы - Справочник MQL4
  • docs.mql4.com
[in] input-параметры пользовательского индикатора, разделенные запятыми. Тип и порядок следования параметров должен соответствовать. Если параметры не указаны, то будут использованы значения по умолчанию.
 
Nikolay Ivanov:

If you want the indicator values in the EA, you do not need to copy the code of the indicator into the EA, you do not even need the code of the indicator. You need to request the indicator values from the EA, this is done with this functionhttps://docs.mql4.com/ru/indicators/icustom


Thanks a lot, but as far as I understand from the description of the function, it takes all of the code of the indicator to get one value, in the place I have specified, that is, to get all of the tops, I will need to calculate the code of the indicator n times (look through all the bars one by one), but I need to compare the order of the tops of the indicator for several timeframes.

And then I need to manually search for vertices

 
ijonhson:

Thanks a lot, but as far as I understood from the description of the function, it executes the whole code of the indicator to get one value, in the place I have specified, that is, to get all tops I will need to calculate the code of the indicator n times (go through all the bars one by one), but I need to compare the order of the tops of this indicator on several timeframes.


The timeframe is an input parameter of the function, you can enter any. The set of bars is read using a cycle, the values can be stored in an array

 
Nikolay Ivanov:

The timeframe is an input parameter to the function, any can be entered. The set of bars is read using a loop, the values can be saved in an array


The question is whether I should calculate the indicator code 900 times per tick (3 timeframes with 300 bars for example), or 3 times; it is clear that icustom is less of a hassle, I put it in the loop and it's done; as an option I saw an address of the array of indicator values passed to the Expert Advisor with a dll, but I don't want to keep the indicator in the set

Reason: