Hello,
I am currently trying to create a ea based on the tdi and heiken ashi indicators.
I came across a problem which I can't fix for some reason.
I created a workaround for an array to save values in variables.


The variable ha_dir_trend_counter is reset before every run of the "array workaround"... (ha_dir_trend_counter = 0;)
The ea then identifies long/short heiken ashi candles. Afterwards 1/-1 is saved in the variable ha_dir (ha_dir = -1; or ha_dir = 1;).
Then I use the array workaround to move all variables one spot up in the array (e.g. ha_dir_bar_12 = ha_dir_bar_11; etc. and save the ha_dir value into ha_dir_bar_1)
Afterwards I am checking the saved "array" for trend pattern but here the problem starts... The reset of the ha_dir_trend_counter doesnt work. It somehow always increments... here is some console output I generated to debug:
2021.09.03 02:48:57.440 2020.01.02 05:00:00 TDI_Version_2 EURUSD,H1: Alert: 0.0
2021.09.03 02:48:57.428 2020.01.02 04:00:00 TDI_Version_2 EURUSD,H1: Alert: 5.0
2021.09.03 02:48:57.428 2020.01.02 04:00:00 TDI_Version_2 EURUSD,H1: Alert: 0.0
2021.09.03 02:48:57.412 2020.01.02 03:00:00 TDI_Version_2 EURUSD,H1: Alert: 4.0
2021.09.03 02:48:57.412 2020.01.02 03:00:00 TDI_Version_2 EURUSD,H1: Alert: 0.0
2021.09.03 02:48:57.400 2020.01.02 02:00:00 TDI_Version_2 EURUSD,H1: Alert: 3.0
2021.09.03 02:48:57.400 2020.01.02 02:00:00 TDI_Version_2 EURUSD,H1: Alert: 0.0
2021.09.03 02:48:57.388 2020.01.02 01:00:00 TDI_Version_2 EURUSD,H1: Alert: 2.0
2021.09.03 02:48:57.388 2020.01.02 01:00:00 TDI_Version_2 EURUSD,H1: Alert: 0.0
2021.09.03 02:48:57.368 2020.01.02 00:00:00 TDI_Version_2 EURUSD,H1: Alert: 1.0
2021.09.03 02:48:57.348 2020.01.02 00:00:00 TDI_Version_2 EURUSD,H1: Alert: 0.0
Why does this happen?
Thanks in advance... I'm sry for the confusing representation of the problem...

