double previousOpen = Open[currentBar - 1]; double previousClose = Close[currentBar - 1];Previous bar is +1
For some or other reason the values of open, close, high, etc. stays the same although the Bar number changes.
Here is the data from my Journal:
2023.09.28 14:59:52.750 2022.08.01 03:00:00 Quatro NZDUSD,H1: BearishEngulfingBar is false BullishEngulfingBar is false currentbar is 1003 currentOpen is 0.64796 previousClose is 0.64934 currentLow is 0.646 currentClose is 0.64717 previousOpen is 0.6472
2023.09.28 14:59:52.750 2022.08.01 03:00:00 Quatro NZDUSD,H1: BuySLsize is 0
2023.09.28 14:59:52.373 2022.08.01 02:00:00 Quatro NZDUSD,H1: BearishEngulfingBar is false BullishEngulfingBar is false currentbar is 1002 currentOpen is 0.64796 previousClose is 0.64934 currentLow is 0.646 currentClose is 0.64717 previousOpen is 0.6472
2023.09.28 14:59:52.373 2022.08.01 02:00:00 Quatro NZDUSD,H1: BuySLsize is 0
2023.09.28 14:59:51.997 2022.08.01 01:00:00 Quatro NZDUSD,H1: BearishEngulfingBar is false BullishEngulfingBar is false currentbar is 1001 currentOpen is 0.64796 previousClose is 0.64934 currentLow is 0.646 currentClose is 0.64717 previousOpen is 0.6472
Not sure if I understood your comment correctly because when I change to
I get the following error:
2023.09.28 14:39:24.164 2022.08.01 01:00:00 Quatro NZDUSD,H1: array out of range in 'Quatro.mq4' (1272,33)
int currentBar = Bars - 1;
Of course, you do. You set currentBar to the oldest in history. There can be no previous.
Not sure if I understood your comment correctly because when I change to
I get the following error:
2023.09.28 14:39:24.164 2022.08.01 01:00:00 Quatro NZDUSD,H1: array out of range in 'Quatro.mq4' (1272,33)
Thank you so much Daniel!
You speak in a way that makes things so much clearer!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am trying to code for to identify engulfing bars but I am getting the wrong open, close, high, low values.
This is the snippet of code:
Am I using the predefined variable "Bars" correctly? if so, why do I get the wrong values?