In an automatic trading system you cannot use graphical elements, hence the error message in the first line of your code…
This is also where the error message in line 30 comes from, you are trying to use a graphical element in an automatic trading system and that is not allowed…
So there are differences between an indicator (may not have buy or sell signals and must end with “return”, etc.) and a trading system (may not contain graphic elements, etc)…
So, make a (right) choice between an indicator and a trading system…