MQL5 zigzag control panel

 
I'm trying to create a control panel for my indicator based on zigzag.

I need to get the first 5 values of the zigzag and the time of these values for the selected timeframe from the panel, which were at the very beginning of the story available (limited number of bars in the settings)

First 6 button for zigzag timeframe (not chart timeframe), 2 more to change zigzag period, last 2 for deviation is unused now, I'll need it later.


Im getting these values, but for some reason only by pressing 2 times on the buttons, I click on the necessary TF and it show the bulshit, and when the second time button is pressed the values are correct.

Who will help to find the error, what is wrong with this?
Files:
zzpanel.mq5  47 kb