So much errors in a so small code, I can see at least 4 major issues : wrong indexing direction combination, variable uninitialized, no error checking when using functions, wrong data synchronisation. Without even talking about the minor issues.
There is no "2 lines of code in red" in what you posted.
because when I pasted his code in metaeditor to try to help him, I saw way more than 2 lines in trouble, like you

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
MQL5 简介:如何编写简单的EA 交易和自定义指标 - MQL5文章
Write it according to the article. It was found that the two lines of code in red swapped positions, resulting in the curve not being displayed. It's really strange.