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

 
Alexey Kozitsyn:
Look at the MovingAverages.mqh file in the terminal's Include folder.

- I need light

- Look at the sun.


No, I get it, but why so rude?

So, we have the penultimate indicator value (yes any value), how to find the current indicator value at bar opening with less gesture?

 
-Aleks-:

- I need light

- Look at the sun.


No, I understand, but why so rude?

So, we have the penultimate value of the indicator (yes, any), how to find the current value of the indicator at bar opening with less effort?

My answer wasn't meant to be rude, I just thought you were confusing the method of averaging and the prices applied. There are examples in this file.

Regarding your question - it depends on how the indicator is calculated: if the indicator is calculated on every tick - just remember the first value of the indicator at the opening of the candle, to use it later. If the indicator is calculated on completed bars - you need to look at it...

 
Alexey Kozitsyn:

My reply was not meant to be rude, it just seemed to me that you were confusing the averaging method and the prices applied. There are examples in this file.

Regarding your question - it all depends on how the indicator is calculated: if the indicator is calculated on every tick - just remember the first value of the indicator at the opening of the candle, to use it later. If the indicator is calculated based on the formed bars - you need to look at...

The indicator is the same - the muwings - it counts on every tick - let's say we are interested in the closing prices of the standard MA.

We have a numeric series 1;2;3;4;5;6(5,1) - the value at the bar opening is in brackets - it will be the bar opening price in the history. MA, let's assume, with a window of 3:

1. (1+2+3)/3=2 (bar - 4)

2. (2+3+4)/3=3 (bar - 3)

3. (3+4+5)/3=4 (bar - 2)

4. (4+5+6)/3=5 (bar - 1)

So we have 4 and 5 - the last and penultimate values of MA at close prices, how can we find without recalculating the entire series (3 numbers), the indicator values at the first tick, if we know that the open price of a bar - the number 5?

 
-Aleks-:

The indicator is still the same - the muwings - it counts on each tick - let's say we are interested in the closing prices of the standard MA.

We have a numeric series 1;2;3;4;5;6(5,1) - in brackets is the value at the bar opening - in the history it will be the bar opening price. MA, let's assume, with a window of 3:

1. (1+2+3)/3=2 (bar - 4)

2. (2+3+4)/3=3 (bar - 3)

3. (3+4+5)/3=4 (bar - 2)

4. (4+5+6)/3=5 (bar - 1)

So we have 4 and 5 - the last and penultimate values of MA close prices, how can we find without recalculating the entire series (3 numbers), the indicator values at the first tick, if we know that the open price of a bar - the number 5?

I don't really understand your description. Let me describe it in my own way. There is a mask. It is recalculated on every tick. It does not matter on what prices it is calculated and what is its averaging method. You want to know the value of this wristwatch at the opening of any candle within the calculated history?
 
Alexey Kozitsyn:
I don't really understand your description. Let me describe it in my own way. There is a wrecker. It is recalculated on every tick. It doesn't matter what prices it is calculated at and what is its averaging method. You want to know the value of this wristwatch at the opening of any candle within the calculated history?

You understand correctly. But method and price are important...

 
-Aleks-:

You understand correctly. But method and price are important...

What really matters is the principle. And the principle is that you need an additional buffer to store these very prices at the time of opening.

So you have to:

1. Declare an additional buffer;

2. To give it an index;

3. Set drawing style to DRAW_NONE (if you don't want the values to be displayed on the chart);

4. In OnCalculate(), when the condition rates_total > prev_calculated is fulfilled - calculate the indicator and write the value into this additional buffer;

That's all:)

Документация по MQL5: Основы языка / Функции / Функции обработки событий
Документация по MQL5: Основы языка / Функции / Функции обработки событий
  • www.mql5.com
Основы языка / Функции / Функции обработки событий - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
-Aleks-:

Think again, do you need Mashka!!!!!!!!? How can you trust this pr...k.! You have mouths that are asking "what are we going to eat?" - this should make you focus on the goal and leave your other needs and interests behind!

You need a more specific topic than muving and other bullshit 100 percent of the time ... a topic that gives you stability for tomorrow ... To know where the money is, you can do it with reports of futsch/options...and other level tools... ....

Here's a simple and useful tip!

 
if(Close[1]<High[i] && Close[1]>Low[i])

i++;

how can i make a condition to be checked on the next bar, not on every tick?

 
Alexey Kozitsyn:

What really matters is the principle. And the principle is that you need an additional buffer to store these same prices at the time of opening.

In other words:

1. Declare an additional buffer;

2. To give it an index;

3. Set drawing style to DRAW_NONE (if you don't want the values to be displayed on the chart);

4. In OnCalculate(), when the condition rates_total > prev_calculated is fulfilled - calculate the indicator and write the value into this additional buffer;

That's all:)

This approach works if the indicator works on the chart - but I need this in the script - on the ready chart.
 
Alexander Antoshkin:

Think again, do you need Mashka!!!!!!!!? How can you trust this pr...k.! You have mouths that are asking "what are we going to eat?" - that should make you focus on the goal and leave your other needs and interests behind!

You need a more specific topic than muving and other bullshit 100 percent of the time ... a topic that gives you stability for tomorrow ... To know where the money is, you can do it with reports of futsch/options...and other level tools... ....

Here's a simple and useful tip!

MA doesn't tell you "where", it helps you figure out "how".

About all these CME reports - there is no clear algorithm for their analysis - at least I haven't seen it - plus the TF for their application requires big risks. If you have a methodology and are ready to tell me about it, I will listen with great interest.

Reason: