Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1237

 
Alexey Viktorov:

The hitch is in the organisation of the code. I tried to look at it, but it is written in such a way that my brain does not perceive it. And I don't know how to explain what the errors are.

I can only advise you to start from the beginning and in order.

  1. Start by singling out every N candle.
  2. Then set a condition to choose which candle to highlight.
And finally learn how to use the debugger.

So I don't have to explain everything here, I gave full comments in my thread. Have a look, if you don't mind...

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

So as not to be too prescriptive, I've given full comments in my thread. Have a look, if you don't mind...

Sergey, I have no desire to get into the code. It's like in the proverb: "If a claw gets stuck in it, the whole bird will be lost". Just the beginning.

   if(rates_total - prev_calculated > 1)
   {
      if(prev_calculated == 0)
      {

When prev_calculated == 0, may there be rates_total - prev_calculated < 1?

 
Alexey Viktorov:

Sergei, I have no desire to get into the code. After all, it's like the proverb: "If a claw gets stuck, the whole bird is lost". Just the beginning.

When prev_calculated == 0, may rates_total - prev_calculated < 1?

Yes, it can. On every tick. If there is no fact of opening a new bar and no change of history, and if it is not the first run. It is always zero in such cases.

 
Artyom Trishkin:

Can. On every tick. In the absence of a new bar opening and no history change, and if not the first run. Always zero in such cases.

Artyom take a closer look. If there are no calculated bars! Then it turns out that there are no bars on the chart at all! Then what is there to count? It probably could have been in MT3 and such over-insurance is stretching from there.

 
Alexey Viktorov:

Sergei, I have no desire to get into the code. After all, it's like the proverb: "If a claw gets stuck, the whole bird is lost". Just the beginning.

When prev_calculated == 0, may rates_total - prev_calculated < 1?

Well, let's face it)))

However, I was surprised... I am not expert in indicators, but from documentation I know exactly, that at startup prev_calculated = 0 and further as much as counted. Total data 100, 100 counted 100-100=0...

But that's not even the point! My condition is not < but > ! The difference is obvious! And that's how I determine the moment of indicator start. Maybe it's not correct according to all canons, but it works! The question is why when the indicator buffers are filled (correct!) the candlesticks are not drawn?

Give me a hint!

 
Alexey Viktorov:

Artyom take a closer look. If there are no calculated bars!!! Then there are no bars on the chart at all!!! What is there to count then? It probably could be in MT3 and such reinsurance comes from there.

You asked a clear question:

Can rates_total - prev_calculated < 1?

and got the same clear answer: in 99.99% of cases :)

You made up the percentage figure yourself :)

 
Artyom Trishkin:

You asked a clear question:

and you got an equally clear answer: 99.99% of the time :)

You came up with the percentage figure yourself :)

And the first part of the line and the question as a whole?

 

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

Total data 100, counted 100 100-100=0...

Read my answers to Artem. There are only two of them.

 
Сергей Таболин: The question is why the candlesticks are not drawn when the indicator buffers are filled (correctly!)?

Point the way!

Are you sure the filling is correct?

I suggested you start by selecting bars after an N number, or at least one last close. Have you tried it? Does it render? Aren't you interested in succeeding with your own brain? You're asking to poke your nose in......... are you offering to show someone how much smarter they are......... I'm certainly not going to do that.

 
Alexey Viktorov:

Are you sure the filling is correct?

I suggested you start by selecting bars after an N number, or at least one last close. Have you tried that? Does it render? Aren't you interested in succeeding with your own brain? You're asking to poke your nose in......... suggesting someone show how much smarter he is......... I'm definitely not going to do that.

Alexey, I am interested )))) But I do not see the error! And there is no shame in learning. And if someone is smarter or more experienced, I don't see anything wrong with that either.

I have just started an indicator with a large input parameter for the size of a candle. I want to have smaller candlesticks.

2020.08.08 10:38:51.184 newCandles (USDJPY,H1)  ~~~~ Предварительный расчёт индикатора.
2020.08.08 10:38:51.343 newCandles (USDJPY,H1)  2019.01.02 06:00:00 >>> Свеча 00000 >> open = 109.419 hihg = 109.462 low = 105.388 close = 105.388 > Сформирована за 122162 тика.
2020.08.08 10:38:51.785 newCandles (USDJPY,H1)  2019.01.03 00:41:15 >>> Свеча 00001 >> open = 105.388 hihg = 109.388 low = 105.268 close = 109.388 > Сформирована за 1336258 тиков.
2020.08.08 10:38:55.673 newCandles (USDJPY,H1)  2019.01.17 21:50:34 >>> Свеча 00002 >> open = 109.388 hihg = 112.398 low = 105.388 close = 105.388 > Сформирована за 11546466 тиков.
2020.08.08 10:38:57.434 newCandles (USDJPY,H1)  2019.08.09 18:57:55 >>> Свеча 00003 >> open = 105.388 hihg = 109.388 low = 104.453 close = 109.388 > Сформирована за 5400916 тиков.
2020.08.08 10:38:59.257 newCandles (USDJPY,H1)  2019.11.07 17:57:24 >>> Свеча 00004 >> open = 109.388 hihg = 112.225 low = 105.384 close = 105.384 > Сформирована за 5555641 тик.
2020.08.08 10:38:59.391 newCandles (USDJPY,H1)  2020.03.06 11:47:26 >>> Свеча 00005 >> open = 105.384 hihg = 105.732 low = 101.377 close = 101.377 > Сформирована за 272724 тика.
2020.08.08 10:38:59.488 newCandles (USDJPY,H1)  2020.03.09 15:37:48 >>> Свеча 00006 >> open = 101.377 hihg = 105.378 low = 101.187 close = 105.378 > Сформирована за 314847 тиков.
2020.08.08 10:39:00.400 newCandles (USDJPY,H1)  2020.03.10 21:05:27 >>> Свеча 00007 >> open = 105.378 hihg = 109.385 low = 103.094 close = 109.385 > Сформирована за 2045775 тиков.
2020.08.08 10:39:03.802 newCandles (USDJPY,H1)  2020.03.19 04:13:11 >>> Свеча 00008 >> open = 109.385 hihg = 111.711 low = 105.385 close = 105.385 > Сформирована за 10250092 тика.
2020.08.08 10:39:03.974 newCandles (USDJPY,H1)  ~~~~ Предварительный расчёт индикатора закончен.

All prices for the candlesticks are calculated and initialed from indicator buffers. All is correct. But there was no rendering. And I don't understand why...

Reason: